第一种:
JS:
<script type="text/javascript"> function temp(obj) { document.all["Country"].innerText=obj; } </script>
form:
mshtml.IHTMLDocument2 currentDoc = (mshtml.IHTMLDocument2) webBrowser1.Document.DomDocument; mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)currentDoc.parentWindow; win.execScript("temp('fdsafadsf)", "javascript");//调用函数temp
第二种:
form:
string[] args = new string[1]; args[0] = "test"; //Test为JS里带参数的方法 webBrowser1.Document.InvokeScript("Test", args); //webBrowser1.Document.InvokeScript("Test1"); //没有参数的方法