1

There are two types of pop-ups, see below: certificate

script error

And I'd like to show the certificate and suppress errors, how could I do that?

FYI, make SuppressScriptErrors=true will also block the certificate.

Dante Jiang
  • 177
  • 1
  • 13

1 Answers1

0

I know it has been a long time since the post of this question, but I found a solution that worked for me.

    // Hides script errors without hiding other dialog boxes.
    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;
    }

ref: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.webbrowser.scripterrorssuppressed?view=net-5.0

for the types: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.htmlelementerroreventargs?view=net-5.0

you could also check the line number / url of the error to suppress some errors.

if the error Description is the Syntax error to mark as handled.

-- also regarding upgrading to the latest version/new versions - the website i am dealing with requires to be IE.