Hi,
I read a couple of the posts that keep reminding the danger of calling C# code from JavaScript, yet your documentation is showing examples on how to do that:
https://www.essentialobjects.com/doc/webbrowser/advanced/jsext.aspxAnd I used it to implement a simple feature allowing my web page to toggle ON/OFF the access to the Debugger. And this works just fine.
Code: JavaScript
var SB_ALLOWED_DEBUG = false;
// Call this function to turn ON/OFF the Inspect menu option in the contextual menu
function ToggleDebug() {
SB_ALLOWED_DEBUG = !SB_ALLOWED_DEBUG;
setDebug(SB_ALLOWED_DEBUG)
}
Code: C#
webContainer.WebView.RegisterJSExtensionFunction("setDebug", new JSExtInvokeHandler(WebView_JSSetDebug));
Code: C#
void WebView_JSSetDebug(object sender, JSExtInvokeArgs e)
{
try
{
WebDebug = (bool)e.Arguments[0];
}
catch (Exception ex)
{
// Handle exception here...
}
}
However as soon as I am going to make this available to my customers they will ask for probably more advanced features, and that is where I am getting cold feet.
So to begin with, is there any potential problem with the simple feature shown here?
What are the dangers one must avoid when implementing this callback pattern using
RegisterJSExtensionFunction.
I thank you many advance for your input on that matter
Regards