I have an application which writes HTML to a WebBrowser control in a .NET winforms application.
I want to detect somehow programatically if the Internet Settings have Javascript (or Active Scripting rather) disabled.
I’m guessing you need to use something like WMI to query the IE Security Settings.
EDIT #1: It’s important I know if javascript is enabled prior to displaying the HTML so solutions which modify the DOM to display a warning or that use tags are not applicable in my particular case. In my case, if javascript isn’t available i’ll display content in a native RichTextBox instead and I also want to report whether JS is enabled back to the server application so I can tell the admin who sends alerts that 5% or 75% of users have JS enabled or not.
Thanks to @Kickaha’s suggestion. Here’s a simple method which checks the registry to see if it’s set. Probably some cases where this could throw an exception so be sure to handle them.
Note: in the interest of keep this code sample short (and because I only cared about the Internet Zone) – this method only checks the internet zone. You can modify the 3 at end of OpenSubKey line to change the zone.