winform环境,webbrowse控件能不能屏蔽掉alert弹出来的提示框?
急呀.........

解决方案 »

  1.   

    禁止脚本执行吧——看 MyIE等的浏览器,可以做到。
      

  2.   

    //项目中添加Micrsoft.mshtml引用
    using mshtml;private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
    {
        IHTMLDocument2 vDocument = (IHTMLDocument2)webBrowser1.Document.DomDocument;
        vDocument.parentWindow.execScript(
            "function alert(str){return;}", "javaScript");
    }//frame结构private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
    {
        IHTMLDocument2 vDocument = (IHTMLDocument2)webBrowser1.Document.DomDocument;
        foreach (IHTMLElement vElement in vDocument.all)
            if (vElement.tagName.ToUpper() == "FRAME")
            {
                IHTMLFrameBase2 vFrameBase2 = vElement as IHTMLFrameBase2;
                vFrameBase2.contentWindow.execScript(
                    "function alert(str){return;}", "javaScript");
            }
    }