Hi everybody,
For some reason I am unable to invoke a javascript method via the WebBrowser.Document.InvokeScript() method if the JS method is contained within a namespace.
If my html page contains the following JS method
<script type="text/javascript">
function foo(myvalue) {
...
}
</script>
then I am able to invoke it without any problems from C# by calling browser.Document.InvokeScript("foo", new object[] {value}).
However, if my JS method is defined with a namespace like this
<script type="text/javascript">
MyNameSpace = window.MyNameSpace
|| {};
MyNameSpace.foo= function(myvalue) {
...
}
</script>
then browser.Document.InvokeScript("MyNameSpace.foo", new object[] {value}) does not have any effect. When I invoke the method via the Chrome console it works fine in both cases, so I am wondering if my C# call is valid. Thoughts?
Your help would be much appreciated.
Thanks,
Oliver