Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to disable JavaScript in webControl hosted in a WinForm

How to disable JavaScript in webControl hosted in a WinForm

Scheduled Pinned Locked Moved C#
javajavascripttutorialquestion
3 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kozu
    wrote on last edited by
    #1

    Hi, I have a WinForm that hosts a WebControl. Is there any way to disable all java scripts in that webControl? thanx

    K 1 Reply Last reply
    0
    • K kozu

      Hi, I have a WinForm that hosts a WebControl. Is there any way to disable all java scripts in that webControl? thanx

      K Offline
      K Offline
      kozu
      wrote on last edited by
      #2

      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.

      K 1 Reply Last reply
      0
      • K kozu

        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.

        K Offline
        K Offline
        kozu
        wrote on last edited by
        #3

        Can anybody help out with this?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups