EO.WebBrowser also supports "JavaScript Extension", which allows you to
register a .NET function as a JavaScript function, thus allowing JavaScript
code to call .NET code. The following code creates a JavaScript function "demoAbout":
//Register extension function "demoAbout"
webView1.RegisterJSExtensionFunction("demoAbout", new JSExtInvokeHandler(WebView_JSDemoAbout))
//Extension handler function
void WebView_JSDemoAbout(object sender, JSExtInvokeArgs e)
{
string browserEngine = e.Arguments[0] as string;
string url = e.Arguments[1] as string;
MessageBox.Show("Browser Engine: " + browserEngine + ", Url:" + url);
}
After the above code, you can call "demoAbout" directly from your JavaScript
code:
//This code will call WebView_JSDemoAbout
demoAbout(window.navigator.appVersion, document.URL);
The above code calls the .NET WebView_JSDemoAbout function. The two arguments
passed to the JavaScript function are also passed to the .NET side available
through the .NET event argument object.
See here for
detailed information on how to call .NET code from JavaScript code.