Jump to content

Disabling context menu in UniURLFrame


Rav

Recommended Posts

Hello,

I have a simple HTML file (report) and want to show it to the user. For this purpose I use TUniURLFrame in a way like this:

uniURLFrame.HTML.LoadFromFile('c:\1.html');

It works perfect except that the browser context menu in uniURLFrame still works regardless of the boDisableMouseRightClick option in UniMainModule.BrowserOptions. It wouldn't have been a large problem but all browsers have the "Save as" option which works dreadful - the saved file is absolute nonsense.

Is it possible to disable the context menu in UniURLFrame or is there another better way of showing the prepared HTML file?

Link to comment
Share on other sites

Hi,

 

If the "iframe" is in a same domain, for now you can try like this:

 

UniURLFrame1->ClientEvents->ExtEvents ... frameload fn:

function frameload(sender, frame, eOpts)
{
  sender.hideMask();
  sender.iframe.contentWindow.oncontextmenu = function(){
    return false
  }
}

Best regards.

  • Like 1
Link to comment
Share on other sites

Yes, sure.

I have just tested UniFrame demo - your code disables the context menu when it's empty. If you go to any URL or load HTML file - the menu appears again.

Maybe your code should be placed whenever UniFrame is changed? I will test it right now...

No it doesn't work either

Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...
On 6/1/2016 at 3:11 AM, Sherzod said:

Hi,

 

Can you try this ?!:


function frameload(sender, frame, eOpts)
{
  sender.hideMask();
  sender.iframe.contentWindow.window.oncontextmenu = function(){
    return false
  }
}

Best regards.

work on chrome , firefox fail

and how did put the event if the uniurlframe is runtime create

 

 

Link to comment
Share on other sites

20 minutes ago, Sherzod said:

For example using ClientEvents.

Can you make a simple testcase to check?

      FUniUrlFrame := TUniURLFrame.Create(TabSheetNew);
      FUniUrlFrame.Name := Name + '_frame';

      FUniUrlFrame.Parent := TabSheetNew;
      FUniUrlFrame.Align := alClient;

      FUniUrlFrame.OnFrameLoaded := UNIFRAME_LOADED;
      FUniUrlFrame.ScreenMask.Target := FUniUrlFrame;
      FUniUrlFrame.ScreenMask.Enabled := true;
      FUniUrlFrame.URL := report_url;

   

   FUniUrlFrame.ClientEvents.ExtEvents.Add('frameload(sender, frame, eOpts){  sender.iframe.contentWindow.window.oncontextmenu = function(){return false}}');

up raise error on runtime

image.png.bdc1b4c3b9c54c3b8fb9fe05bd6536cf.png

 

Link to comment
Share on other sites

2 minutes ago, Sherzod said:

FUniUrlFrame.ClientEvents.ExtEvents.Add('frameload = function frameload(sender, frame, eOpts){...

      FUniUrlFrame.ClientEvents.ExtEvents.Add('frameload = function frameload(sender, frame, eOpts){  sender.iframe.contentWindow.window.oncontextmenu = function(){return false}}');

the code is work but right click on frame is show/active

Link to comment
Share on other sites

actually a local url, just make a test if it's an external domain for tes the funcion

   FUniUrlFrame.ClientEvents.ExtEvents.Add('frameload = function frameload(sender, frame, eOpts){  sender.iframe.contentWindow.window.oncontextmenu = function(){return false}}');

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...