Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read Javascript variable from Web Browser control

I am trying to read the value of a Javascript variable which is loaded and called from a WebBrowser control on my form.

Example:

index.html refers to a javascript called 'test.js' On test.js, several variables are created and populated.

index.html then makes a call to this JS.

Index.html is loaded and displayed into the WebBrowser control.

I've found lots of help on how to call/invoke functions that reside in the web browser control. How how can I easily read a variable value?

like image 622
AllStar11 Avatar asked Jul 29 '11 17:07

AllStar11


1 Answers

You could do:

Document.InvokeScript("eval", new object[] { "my_var_name" });
like image 102
Juan Avatar answered Oct 05 '22 18:10

Juan