Closed GoogleCodeExporter closed 9 years ago
Ok, I found a work around which only works with the .NET v4 of the component.
Basically I need to put the code in the Navigated event as the objects get
unloaded each time a new page is loaded. Then, using the ScriptManager, I get
a reference to the global script object. Then a call SetProperty which
attaches the .NET object to the script. Once this is done, I am able to invoke
the .NET object directly from script!
Code (.NET):
public class TEST
{
public double Foo(double a)
{
a++;
return a;
}
}
...
private void webKitBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
JSObject o;
o = webKitBrowser1.GetScriptManager.GlobalContext.GetGlobalObject();
o.SetProperty("TEST", new TEST());
}
Script (JS):
<script type="text/javascript" language="javascript">
<!--
alert(TEST.Foo(1)); // Prints 2
//-->
</script>
Original comment by vbgu...@gmail.com
on 9 May 2012 at 6:26
windowScriptObject() is not implemented in WebKit but the alternative option is
the one you stated in your 2nd post. Issue closed.
Original comment by tsumalis96@gmail.com
on 10 May 2012 at 7:05
Original issue reported on code.google.com by
vbgu...@gmail.com
on 5 May 2012 at 4:34