private void Window_Error(object sender, HtmlElementErrorEventArgs e) 
        {            e.Handled = true;
        }
         void axBrowser_NavigateError(object pDisp, ref object URL, ref object Frame, ref object StatusCode, ref bool Cancel)
        {        } 我用Window_Error捕捉不到脚本错误事件,被axBrowser_NavigateError事件截获了,但是在axBrowser_NavigateError我要处理网页错误信息如404错误信息等等,请问如何彻底屏蔽脚本错误信息啊,包括JS、VBscript脚本。

解决方案 »

  1.   

            private void Window_Error(object sender, HtmlElementErrorEventArgs e) 
            {             //e.Handled = true; 注释掉
            }
      

  2.   

    或者this.Browser.ScriptErrorsSuppressed = true;
      

  3.   

    Window_Error事件还是没有被触发  谢谢
      

  4.   


    // Hides script errors without hiding other dialog boxes.
    // This method call in MainForm.Load handler.
    private void SuppressScriptErrorsOnly(WebBrowser browser)
    {
        // Ensure that ScriptErrorsSuppressed is set to false.
        browser.ScriptErrorsSuppressed = false;    // Handle DocumentCompleted to gain access to the Document object.
        browser.DocumentCompleted +=
            new WebBrowserDocumentCompletedEventHandler(
                browser_DocumentCompleted);
    }private void browser_DocumentCompleted(object sender, 
        WebBrowserDocumentCompletedEventArgs e)
    {
        ((WebBrowser)sender).Document.Window.Error += 
            new HtmlElementErrorEventHandler(Window_Error);
    }private void Window_Error(object sender, 
        HtmlElementErrorEventArgs e)
    {
        // Ignore the error and suppress the error dialog box. 
        e.Handled = true;
    }