When I navigate some website using WebBrower control but it show alert box from java script page's how to disable its?
2 Answers
You can use the following code for this:
HtmlElement head = myWebBrowser.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = myWebBrowser.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
string alertBlocker = @"window.alert = function () { };";
element.text = alertBlocker;
head.AppendChild(scriptEl);
myWebBrowser.ScriptErrorsSuppressed = true;
the source took from : http://moshez.blogspot.co.il/2013/08/c-disable-alert-box-javascript-in-c.html