首页  编辑  

获得网页中java的变量值

Tags: /C#/界面处理/WebBrowser/   Date Created:

//

--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;

}