Welcome Guest Search | Active Topics | Sign In | Register

EO.WebBrowser - error - callback after EvalScript Options
vincentaugereau
Posted: Saturday, November 30, 2019 5:46:05 AM
Rank: Newbie
Groups: Member

Joined: 12/14/2015
Posts: 2
Hello,

I use EO.WebBrowser.WinForm v19.2.91.0
Visual Studio 2019 c#

I have a javascript code calling a c# function, for example : eoapi.extInvoke("quitter", []);

After this, c# send a callback to JS like this : web.InvokeFunction (fonction,code);

So, I have this bug :
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.


I try with a thread but it doesn't work too.

What can I do to send a callback ?


simple code c#
private void Form1_Load(object sender, EventArgs e)
{
EO.Base.Runtime.EnableEOWP = true;

EO.WebBrowser.Runtime.RemoteDebugPort = 1234;

EO.WebBrowser.Runtime.AddLicense("[ma_licence]");

webControl1.WebView.Url = "file://C:/test.html";

webView1.JSExtInvoke += new JSExtInvokeHandler(onReceiveJsMessage);
}

private void onReceiveJsMessage(object sender, JSExtInvokeArgs e)
{

webView1.InvokeFunction("alert('" + e.FunctionName + "')");

}

eo_support
Posted: Monday, December 2, 2019 5:07:18 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

When you use JavaScript extension function, you can NOT call back into the JavaScript engine before your function returns. Allowing so would cause JavaScript engine to be re-entered and this is not allowed. So you must change your code structure to work around this.

One of the easiest way to get around this restriction is to use QueueScriptCall instead. Note that since QueueScriptCall is asynchronous, this means your code inside your extension function can not depend on the return value of this second JavaScript call.

Thanks!


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.