the following code disable :
- Alert window.
- Print window
- confirm window.
/************Disable alert/print function()**********************/ HtmlElement head = WebBrowser1.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = WebBrowser1.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement; string alertBlocker = @"window.alert = function () { }; window.print=function () { }; window.confirm=function () { }; "; element.text = alertBlocker; head.AppendChild(scriptEl); WebBrowser1.ScriptErrorsSuppressed = true; /****************************************************************/
Enjoy!
Prezado, teria o mesmo exemplo em delphi?
ReplyDeleteDear, would the same example in delphi?
Hi,
ReplyDeleteHow to use VB.NET (Visual basic) this code, i want suppress on youtube "leave this page" alert.
Thanks.