GeckoWebBrowser is accessing an invalid URL, a message box always appears

www.addssds333fdsd.com.cn could not be found. Check the name and try again.

 GeckoWebBrowser _webA = new GeckoWebBrowser();
 _webA.Navigate("www.addssds333fdsd.com.cn");

When I access the wrong URL, the application will display a message box.

How to catch an exception or remove a message box.

+4
source share
1 answer

You need to implement the nsIPromptServcice2 and nsIPrompt interfaces

There you will get a list of methods (for example Alert();) where you simply do not provide an implementation. This will catch the exception.

Create the following class (you will need to provide an implementation for many methods such as Alert, Confirm, Prompt, etc.

public class FilteredPromptService : nsIPromptService2, nsIPrompt
{

    public void Alert(string dialogTitle, string text)
    {
         //do your stuff here
    } 
    //... other methods to follow
}

, - - (, Application_Startup() WPF) :

PromptFactory.PromptServiceCreator = () => new FilteredPromptService();

, , PromptService , GeckoBrowser .

+1

Source: https://habr.com/ru/post/1661556/


All Articles