How to disable JavaScript in webControl hosted in a WinForm
-
Hi, I have a WinForm that hosts a WebControl. Is there any way to disable all java scripts in that webControl? thanx
I tried injecting a script that would prevent the control to popup other windows, but it did not work In the webBrowser1_Navigated handler: HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = webBrowser1.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement; string alertBlocker = "window.alert = function () { }"; element.text = alertBlocker; head.AppendChild(scriptEl); Also, when I right-click 'view page source' I don't see the script I injected.
-
I tried injecting a script that would prevent the control to popup other windows, but it did not work In the webBrowser1_Navigated handler: HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = webBrowser1.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement; string alertBlocker = "window.alert = function () { }"; element.text = alertBlocker; head.AppendChild(scriptEl); Also, when I right-click 'view page source' I don't see the script I injected.