Welcome Guest Search | Active Topics | Sign In | Register

How to transfer a JSFunction to c# Options
zs949
Posted: Tuesday, February 2, 2016 3:35:40 AM
Rank: Newbie
Groups: Member

Joined: 1/4/2016
Posts: 4
c# code:

m_WebView.RegisterJSExtensionFunction("InvokeCallback", new JSExtInvokeHandler(WebView_JSInvokeCallback));

public void WebView_JSInvokeCallback(object sender, JSExtInvokeArgs e)
{
//e.Arguments[0] is show a function, but how to get this?,i want get this function, and EvalScript this.
//e.Arguments[1] is "a123"
}

js code:

InvokeCallback(function (msg) {
var element = document.getElementById("p2");
element.innerHTML = msg;
},"a123");

so,is there a way to pass a JSFunction to c#? thx
eo_support
Posted: Tuesday, February 2, 2016 10:42:12 AM
Rank: Administration
Groups: Administration

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

I am not sure if you can invoke back into the JavaScript engine from your C# side JS extension handler because this would cause re-entering the JavaScript engine. Have you tried to cast it to a JSFunction and then call it's Invoke method?

http://www.essentialobjects.com/doc/eo.webbrowser.jsfunction.invoke_overloads.aspx

Thanks!
zs949
Posted: Wednesday, February 3, 2016 12:23:11 AM
Rank: Newbie
Groups: Member

Joined: 1/4/2016
Posts: 4
Thank you for your prompt reply!

I solve this. 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.