Search code examples
javascriptc#winformsgeckofx

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. 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.

Anybody knows where I could find a reference at last ?


Solution

  •       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.