您的位置:首页 > Web前端 > JavaScript

VS2005 WInform程序如何调用js

2007-11-13 16:37 501 查看

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; //获取页面元素值
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: