Reputation: 75
I'm using a webbrowser control in visual studio 2010 to invoke JS script.I'm able to call a function from the web browser but i'm looking to get a varible value from JS and use it in the winform.
I have this JS code for exemple :
<script type="text/javascript">
function f() {
var val=0;
return val;
}
</script>
The C# code is not working :
webBrowser.Document.InvokeScript("f");
what's the right way to invoke the JS function and get the variable value?
Upvotes: 1
Views: 1956
Reputation: 19093
InvokeScript will return the value which the javascript function returns. You just need to be a bit careful about it's type. Numbers and strings will be returned a c# strings.
Upvotes: 1