Rank: Advanced Member Groups: Member
Joined: 1/2/2017 Posts: 32
|
Please help,
EO.WebBrowser out of the box provides the means to make custom context menus, too include adding a "Reload" option as such:
MyWebViewControl.BeforeContextMenu += new EO.WebBrowser.BeforeContextMenuHandler(MyBeforeContextMenu);
public void MyBeforeContextMenu(object objSender, EO.WebBrowser.BeforeContextMenuEventArgs bcmea) { bcmea.Menu.Items.Clear(); bcmea.Menu.Items.Add(new EO.WebBrowser.MenuItem("Refresh", EO.WebBrowser.CommandIds.Reload)); }
The problem is that the "Reload" context menu will reload the entire WebView control every time, even when launched over a frame object (IFRAME). In "normal" browsers, like IE, the "Refresh" context menu only refreshes the "target" frame, when invoked over a frame.
How can we do this with EO?
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, This is not directly supported since we do not exposes frame object. However you can do it through JavaScript (by calling WebView.EvalScript) and call this method on the frame you wish to reload: https://developer.mozilla.org/en-US/docs/Web/API/Location/reloadYou will need to write JavaScript code to find the target frame and then call the above method on that frame's location object, then call WebView.EvalScript to run that code. Thanks!
|
Rank: Advanced Member Groups: Member
Joined: 1/2/2017 Posts: 32
|
Thanks for the reply. Sadly, I had to implement some JavaScript along the lines you mentioned, to put a bandaid on this.
The problem with your solution, is that it does not account for nested IFRAMES, that are possibly not owned/controlled by the developer, and possibly even cross domains so that CORS incompatibility prevents JavaScript on other IFRAMES from "reaching" into inner IFRAMES, to figure out which one to refresh. As an example, imagine, one uses the EO WebView control to show HTML that has an IFRAME in it to a Microsoft web site, that in turn, has an IFRAME inside of it, to a Google website. In this example, the developer does not own/control either the Microsoft site or the Google site, and as they are different domains, CORS will surely prevent JavaScript from the developers page to reach into the Microsoft IFRAME, to then reach into the Google IFRAME.
The above said, all browsers to my knowledge, and the built in Windows Browser control, all allow users to right-click on a target IFRAME, and use Refresh for just the targeted IFRAME.
Well, thanks again, and if you would please, forward this situation to your dev team. Maybe they can add this functionality in.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, Thank you very much for your feedback and we will look into it and see what we can do for this case. CORS should not prevent WebView.EvalScript. CORS will prevent a page that comes from a Microsoft site from accessing a page that comes from a Google site, but the script from WebView.EvalScript comes from neither a Microsoft site nor a Google site, instead it comes from the developer and it is always trusted, so CORS will not block it. You can think of WebView.EvalScript as the script console of the Chrome browser's built-in developer tools. CORS restrictions does not apply here as otherwise it would severely limit the usefuless of the feature. The same principle applies for WebView.EvalScript. Also JavaScript code is not really a bandaid in our solution. It is in fact the first class citizen of our product --- we actively encourage our users to use JavaScript instead of strong typed .NET wrappers for a number of reasons. You can see these reasons explained in more details on this page: https://www.essentialobjects.com/doc/webbrowser/advanced/jsdom.aspxThe bottom section of this page explained the advantages of using JavaScript over using strong typed .NET objects. Once again thanks for your feedback. Please feel free to share with us if there is anything else. Thanks!
|