禁用GeckoFX确认消息

我在我的Windows应用程序中使用Gecko Web浏览器版本21.0.1和.net Framework 4.0。

当我导航到某些网页时,我会弹出确认消息:

此网页正被重定向到新位置。 是否要将您输入的表单数据重新发送到新位置?

如何禁用此类消息?

到目前为止,我已经尝试了以下设置,但它们没有帮助:

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; 

您可以尝试提供自己的nsIPromptService2 / nsIPrompt实现。

在程序启动时尽早运行(尽管在XPCom.Initalize之后)

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

FilteredPromptService的定义如下:

 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) } 

您还需要确保未启用错误页面:

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