winform上嵌套WebBrowser控件,可以从c#代码里面调用该控件内html的js方法。
示例代码:
setLocation方法是browser控件内的html上的js方法名称,第二个参数是setLocation方法的入参。
this.browser.Document.InvokeScript("setLocation", new object[] { this._lng, this._lat })如果你用的是 webbrowser 的话,可以执行js脚本,或者出发页面上的html控件的事件来达到目的:我不知道你的应该,我列两个你参考一下吧
webBrowser1.Document.GetElementById("userid").InnerText = Account
webBrowser1.Document.GetElementById("password").InnerText = textBox2.Text
IHTMLDocument2 id2 = webBrowser1.Document.DomDocument as IHTMLDocument2
IHTMLWindow2 win = id2.parentWindow
win.execScript("CheckAndLogin()", "javascript")
或者执行按钮事件
webBrowser1.Document.GetElementById("card_number").InnerText = Account
webBrowser1.Document.GetElementById("card_password").InnerText = textBox2.Text
HtmlElement elemButton = webBrowser1.Document.GetElementById("select_order")
mshtml.HTMLInputElement button = (mshtml.HTMLInputElement)(elemButton.DomElement)
button.click()