Disable GeckoFX confirm messages

不想你离开。 提交于 2019-12-10 11:33:43

问题


I am using Gecko Web browser version 21.0.1 and .net Framework 4.0 in my windows application.

When I navigate to certain web pages I get Pop up confirm message:

This web page is being redirected to a new location. Would you like to resend the form data you have typed to the new location?

How can I disable this kind of messages?

So far I have tried the following settings, but they didn't help:

GeckoPreferences.User["security.warn_viewing_mixed"] = false;
GeckoPreferences.User["plugin.state.flash"] = 0;
GeckoPreferences.User["browser.cache.disk.enable"] = false;
GeckoPreferences.User["browser.cache.memory.enable"] = false;

回答1:


You could try providing you own nsIPromptService2 / nsIPrompt implementation.

Run this early on program start up (Although after XPCom.Initalize)

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

Where FilteredPromptService is defined something like this:

internal class FilteredPromptService : nsIPromptService2, nsIPrompt
{
    private static PromptService _promptService = new PromptService();

    public void Alert(nsIDOMWindow aParent, string aDialogTitle, string aText)
    {
        if(/*want default behaviour */)
        {
         _promptService.Alert(aDialogTitle, aText);
        }
        // Else do nothing 
    }

    // TODO: implement other methods in similar fashion. (returning appropriate return values)
}

You will also need to make sure that error pages are not enabled:

GeckoPreferences.User["browser.xul.error_pages.enabled"] = false;


来源:https://stackoverflow.com/questions/28896060/disable-geckofx-confirm-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!