Welcome Guest Search | Active Topics | Sign In | Register

Access the EO.WebBrowser.DOM.Document and unsafe backwards compatibility? Options
Gregory Riggs
Posted: Sunday, September 25, 2022 6:44:58 PM
Rank: Newbie
Groups: Member

Joined: 3/19/2020
Posts: 5
Hi,

[1] Is there any way to access the EO.WebBrowser.DOM.Document object from C# code that was called from JavaScript using the eoapi.extInvoke method? We used to be able to do this in the 2017 version of EO.WebBrowser using the following code:

EO.WebBrowser.DOM.Document dom = (Document)webBrowser.WebView.GetDOMWindow().document;

However, this no longer works and returns null when using the 2022 version of EO.WebBrowser.

[2] I'm guessing the answer is probably no, but just wanted to confirm to be sure. Our code makes multiple calls back and forth between JavaScript and C# code via eoapi.extInvoke and webBrowser.WebView.EvalScript. This used to work 2017 version of EO.WebBrowser but no longer works using the 2022 version of EO.WebBrowser. It now fails with an error that looks like this:

"EvalScript failed because it is not safe to run JavaScript code at this moment. This can occur if you are inside event handlers of certain WebView events such as JSExtInvoke. In that case please consider delaying EvalScript calls until after the event handler returns."

It will take significant effort to refactor our code to avoid the multiple calls back and forth between C# and JavaScript. Is there any way to put the EO.WebBrowser into a backwards compatibility mode (e.g., an unsafe mode) to continue to do this using the 2022 version of EO.WebBrowser?

Thanks,
Gregory
eo_support
Posted: Monday, September 26, 2022 2:15:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
This was disabled on purpose. This post contains more information on why it was disabled:

https://www.essentialobjects.com/forum/postst11933_Return-Result-From-QueueScriptCall-Inside-RegisterJSExtensionFunction.aspx#50407

In early version when this wasn't disabled it is possible for you to do with your code but it can also cause many other problems, particular browser engine crashes due to JavaScript engine has been re-entered. So a backwards compatiblity mode isn't really an option since it can eventually lead to mysterious crash due to the JavaScript engine has been used in way it is not designed to do, which means those issues are unfixable either.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.