用webborwer导航一个网页,网页中有一个Jscript变量,如何在程序中读取它??

解决方案 »

  1.   

    //项目中添加Micrsoft.mshtml引用
    --c:\temp\temp.htm--
    <html>
    <script language="JavaScript">
    var Temp = "Zswang 路过 :)";
    </script>
    </html>using mshtml;private void Form1_Load(object sender, EventArgs e)
    {
        webBrowser1.Navigate(@"c:\temp\temp.htm");
    }private void button1_Click(object sender, EventArgs e)
    {
        IHTMLDocument2 vDocument = webBrowser1.Document.DomDocument as IHTMLDocument2;
        IHTMLWindow2 vWindow = vDocument.parentWindow;
        vWindow.execScript("document.title=Temp;", "JavaScript");
        Text = vDocument.title;
    }