在webBrowser中有的时候会弹出一个确定窗口,如何用代码将其关闭,或者说如何用代码屏蔽不让他弹出

解决方案 »

  1.   


    using mshtml; 
    using SHDocVw; 
    private void Form1_Load(object sender, EventArgs e) 

    this.webBrowser1.Navigate("http://localhost:28512/test/Default.aspx"); 
    SHDocVw.WebBrowser wb = this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser; 
    wb.NavigateComplete2 += new SHDocVw.DWebBrowserEvents2_NavigateComplete2EventHandler(wb_NavigateComplete2); } void wb_NavigateComplete2(object pDisp, ref object URL) 

    mshtml.IHTMLDocument2 doc = (this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser).Document as mshtml.IHTMLDocument2; 
    doc.parentWindow.execScript("function alert(str){return ''}", "javascript"); 

      

  2.   

    //指定webbrowser控件是否在页面中显示脚本错误
    this.webBrowser1.ScriptErrorsSuppressed = false;