Disable GeckoFX confirm messages

纵然是瞬间 提交于 2019-12-06 12:19:55

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