WebBrowser webBrowser
=
new
WebBrowser();
webBrowser.Navigate(AppDomain.CurrentDomain.BaseDirectory + " /Test.html " ); // 加载网页
mshtml.IHTMLDocument2 html = (mshtml.IHTMLDocument2) this .webBrowser.Document.DomDocument;
// mshtml.IHTMLDocument2 html = (mshtml.IHTMLDocument2)this.webBrowser.Document; // 此方法在VS2005中不适用
mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)html.parentWindow;
win.execScript( " document.getElementById('text').value += trans(); " , " javascript " ); // 使用JS
this .richTextBox1.Text += this .webBrowser.Document.GetElementById( " text " ).InnerHtml; // 获取页面元素值
webBrowser.Navigate(AppDomain.CurrentDomain.BaseDirectory + " /Test.html " ); // 加载网页
mshtml.IHTMLDocument2 html = (mshtml.IHTMLDocument2) this .webBrowser.Document.DomDocument;
// mshtml.IHTMLDocument2 html = (mshtml.IHTMLDocument2)this.webBrowser.Document; // 此方法在VS2005中不适用
mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)html.parentWindow;
win.execScript( " document.getElementById('text').value += trans(); " , " javascript " ); // 使用JS
this .richTextBox1.Text += this .webBrowser.Document.GetElementById( " text " ).InnerHtml; // 获取页面元素值