我在我的 Windows 应用程序中使用 Gecko Web 浏览器版本 21.0.1 和 .net Framework 4.0。
当我导航到某些网页时,我会弹出确认消息:
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?
如何禁用此类消息?
到目前为止,我已经尝试了以下设置,但它们没有帮助:
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;
关于c# - 禁用 GeckoFX 确认消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28896060/