1.
mshtml.IHTMLWindow2 win = (mshtml.IHTMLWindow2)doc2.parentWindow;//拿到html对象
win.execScript("changeRegImg()", "javascript");//调用JS
用Microsoft.mshtml.dll可以再c#程序里操作IE。
2.
ShellWindows m_IEFoundBrowsers = new ShellWindowsClass();
foreach (InternetExplorer Browser in m_IEFoundBrowsers){
if (Browser.Document is HTMLDocumentClass)
{
HTMLDocumentClass doc2 = Browser.Document as HTMLDocumentClass;
HTMLScriptElement script = (HTMLScriptElement)doc2.createElement("script");
script.text = "alert('a');";
HTMLBodyClass body = doc2.body as HTMLBodyClass;
body.appendChild((IHTMLDOMNode)script);
}
}