使用 WebBrowser 操作 js

winForm下的WebBrowser控件可以执行当前页面已存在的js,但不支持自定义js操作。

因此要使用引用Microsoft.mshtml.dll来实现。

该dll里面的接口各负责不同的工作。

mshtml.IHTMLWindow2  可负责js操作。

   mshtml.IHTMLDocument2 currentDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument;
                mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)currentDoc.parentWindow;
               win.execScript("F1('日本')", "javascript");//调用函数F1

原文地址:https://www.cnblogs.com/diulela/p/2243445.html