从 Web 浏览器控件读取 Javascript 变量 [英] Read Javascript variable from Web Browser control
问题描述
我正在尝试读取从表单上的 WebBrowser 控件加载和调用的 Javascript 变量的值.
I am trying to read the value of a Javascript variable which is loaded and called from a WebBrowser control on my form.
示例:
index.html 指的是一个名为test.js"的 javascript在 test.js 上,创建并填充了几个变量.
index.html refers to a javascript called 'test.js' On test.js, several variables are created and populated.
index.html 然后调用这个 JS.
index.html then makes a call to this JS.
Index.html 被加载并显示到 WebBrowser 控件中.
Index.html is loaded and displayed into the WebBrowser control.
我找到了很多关于如何调用/调用驻留在 Web 浏览器控件中的函数的帮助.如何轻松读取变量值?
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?
推荐答案
你可以这样做:
Document.InvokeScript("eval", new object[] { "my_var_name" });
这篇关于从 Web 浏览器控件读取 Javascript 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!