var doc = this.WebBrowser.Document.DomDocument as IHTMLDocument2; var win = doc.parentWindow as IHTMLWindow2; string jscode = @" //这里写JS代码 "; win.execScript(jscode, "javascript");