GeckoWebBrowser access an incorrect URL,Always pop up message box

前端 未结 1 419
醉梦人生
醉梦人生 2021-01-19 15:30

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

 GeckoWebBrowser _webA = new GeckoWebBrowser();
 _webA.Navigate(\"www.adds         


        
相关标签:
1条回答
  • 2021-01-19 15:50

    You need to implement the nsIPromptServcice2 and nsIPrompt interfaces

    There you will get a list of methods (e.g. Alert();) where you simply don't provide an implementation. That will 'catch' the exception.

    Create a following class (you will need to provide implementation for a bunch of 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
    }
    

    Then, somewhere at the startup of the browser app (maybe in Application_Startup() in case of WPF), assign the prompt service:

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

    Also, please notice that the above PromptService is static, so this will be applied to all instances of GeckoBrowser in your application.

    0 讨论(0)
提交回复
热议问题