Disabling alert window in WebBrowser control

i am using VS 2005 and WebBrowser control. When i using component to navigate to specified page i get scenario error, like “On this page javascript scenario error” and two buttons: yes or no executing scenario. How to prevent alert windows and continue browsing without this messages?

  • Returning HTML from JSON webservice - what is the “.d”?
  • MVC 4 Razor - Creating a dynamic DropDownList
  • How to access 3rd Party cookies in the Browser?
  • Where can I find unit tests for regular expressions in multiple languages?
  • How to disable TextBox on client-side click on CheckBox
  • How to: Back button support “Ajax”
  • How to disable Javascript in mshtml.HTMLDocument (.NET)
  • display messagebox in asp.net
  • Hide a datagrid column with Javascript?
  • Export FASTREPORT print as PDF
  • JavaScript htmlentities French
  • Sharepoint. Show list item version history dialog
  • 3 Solutions collect form web for “Disabling alert window in WebBrowser control”

    Try

    WebBrowser1.ScriptErrorsSuppressed = true;
    

    Try this

    HtmlElement head = WebBrowser1.Document.GetElementsByTagName("head")[0];
    HtmlElement scriptEl = WebBrowser1.Document.CreateElement("script");
    IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
    string alertBlocker = @"window.alert = function () { }; window.confirm=function () { };";
    element.text = alertBlocker;
    head.AppendChild(scriptEl);
    WebBrowser1.ScriptErrorsSuppressed = true;
    

    Source :
    http://moshez.blogspot.co.il/2013/08/c-disable-alert-box-javascript-in-c.html

        Private Sub WebBrowser1_StatusTextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebBrowser1.StatusTextChanged
            On Error Resume Next
            Dim head As HtmlElement = WebBrowser1.Document.GetElementsByTagName("head")(0)
            Dim script As HtmlElement
            script = WebBrowser1.Document.CreateElement("script")
            script.SetAttribute("type", "text/javascript")
            Dim alertBlocker As String = "window.alert = function () { }; window.confirm=function () { }; "
            script.SetAttribute("text", alertBlocker)
            head.AppendChild(script)
        End Sub