private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { IHTMLWindow2 ihtmlWin = webBrowser1.Document.Window.DomWindow as IHTMLWindow2; //屏蔽alert string s = "var aaa=function(){return true;} window.alert = aaa; window.confirm = aaa; window.open = aaa; window.showModalDialog = aaa;"; ihtmlWin.execScript(s, "javascript"); }