简体   繁体   English

禁用JavaScript警报GeckoFX C#

[英]Disable JavaScript Alerts GeckoFX C#

I'm trying to disable JavaScript alert in GeckoFX-33 + xulrunner 33 ( winforms c# ) but I can't find a solution. 我正在尝试在GeckoFX-33 + xulrunner 33(winforms c#)中禁用JavaScript警报,但找不到解决方案。 I check the example codes, source code but I just can't find something that blocks the alert out. 我检查了示例代码和源代码,但是我找不到阻止警报的内容。 I searched in about:config as well without success. 我也搜索about:config ,但没有成功。

Anybody knows where I could find a reference at last ? 有人知道我最后在哪里可以找到参考吗?

In prior versions, you could do 在以前的版本中,您可以

webBrowser.JavascriptError += (sender, error) => {
  // do something
}

However according to issue 7 on geckofx 33 , there's some work that needs to be done to support the new debugging interface: 但是,根据geckofx 33上的第7期 ,需要做一些工作来支持新的调试接口:

the geckofx service jsdIDebuggerService was removed from firefox 33. the JavascriptError event implementation used this service. 从firefox 33中删除了geckofx服务jsdIDebuggerService。JavascriptError事件实现使用了该服务。 So the JavascriptError event handler needs to be reimplemented using firefox new debugging interface. 因此,需要使用firefox新的调试接口重新实现JavascriptError事件处理程序。

      geckoWebBrowser1.JavascriptError += (sender, error) =>
        {
            GeckoWebBrowser browser = geckoWebBrowser1;
            string text = "window.alert = function(){};";
            using (AutoJSContext context = new AutoJSContext(browser.Window.JSContext))
            {
                string result;
                //toolStripLabel1.Text = "was is loaded?";

                context.EvaluateScript(text, (nsISupports)browser.Window.DomWindow, out result);
            }
        };

Here is the final code for Gecko 29. 这是Gecko 29的最终代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM