1

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.