Will the IE9 WebBrowser Control Support all of IE9's features, including SVG?

107,613

Solution 1

The IE9 "version" of the WebBrowser control, like the IE8 version, is actually several browsers in one. Unlike the IE8 version, you do have a little more control over the rendering mode inside the page by changing the doctype. Of course, to change the browser mode you have to set your registry like the earlier answer. Here is a reg file fragment for FEATURE_BROWSER_EMULATION:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"contoso.exe"=dword:00002328

Here is the complete set of codes:

  • 9999 (0x270F) - Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
  • 9000 (0x2328) - Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
  • 8888 (0x22B8) -Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
  • 8000 (0x1F40) - Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
  • 7000 (0x1B58) - Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.

The full docs:

http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation

Solution 2

WebBrowser control will use whatever version of IE you have installed, but for compatibility reasons it will render pages in IE7 Standards mode by default.

If you want to take advantage of new IE9 features, you should add the meta tag <meta http-equiv="X-UA-Compatible" content="IE=9" > inside the <head> tag of your HTML page.

This meta tag must be added before any links to CSS, JavaScript files etc that are also in your <head> to work properly though (only other <meta> tags or the <title> tag can come before it).

An alternative is to add a registry entry to:

HKLM > SOFTWARE > Microsoft > Internet Explorer > Main > FeatureControl > FEATURE_BROWSER_EMULATION

And in there add 'myApplicationName.exe' with value '9000' to force the WebBrowser control to display pages in IE9 mode. Though there are other values you can use too too, note that these docs aren't entirely accurate as it does not seem possible to get a page to render in IE 8 mode whatever value you use.

Adding the registry key to the same path in HKCU instead of HKLM will also work - this is useful as writing to HKLM requires admin privileges where as HKCU does not.

Solution 3

Thank goodness I found this. The following is extremely important:

<meta http-equiv="X-UA-Compatible" content="IE=9" >

Without this, none of the reports I'd been generating would work post IE9 install despite having worked great in IE8. They would show up properly in a web browser control, but there would be missing letters, jacked up white space, etc, when I called .Print(). They were just basic HTML that should be capable of being rendered even in Mosaic. heh Not sure why the IE7 compatibility mode was going haywire. Notably, you could .Print() the same page 5 times and have it be missing different letters each time. It would even carry over into PDF output, so it's definitely the browser.

Solution 4

A note about 64bit Windows which seems to trip up a few folks. If your app is running under 64bit Windows, you likely have to set the DWORD under [HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION] instead.

Solution 5

Just to be complete...

For 32 bit OS you must add a registry entry to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

*******OR*******

For 64 bit OS you must add a registry entry to:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

This entry must be a DWORD, with the name being the name of your executable, that hosts the Webbrowser control; i.e.:

myappname.exe (DON'T USE "Contoso.exe" as in the MSDN web page...it's just a placeholder name)

Then give it a DWORD value, according to the table on:

http://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx#browser_emulation

I changed to 11001 decimal or 0x2AF9 hex --- (IE 11 EMULATION) since that isn't the DEFAULT value (if you have IE 11 installed -- or whatever version).

That MSDN article contains notes on several other Registry changes that affects Internet Explorer web browser behavior.

Share:
107,613

Related videos on Youtube

Omkar
Author by

Omkar

Day starts with running to office and work plan for that day. Evening starts with exciting learnings on new and upcoming technologies. Leisure time spent activity is enjoying with family, cycling for fresh mind and health, watching movies.

Updated on March 27, 2020

Comments

  • Omkar
    Omkar about 4 years

    I recently upgraded to IE9-beta. Now, In my .Net (3.5) WinForm application I want to use WebBrowser control.

    So my question is, whether the WebBrowser control will exhibit all properties and functions of IE9?

    My concern is, I want to render some SVG graphics on it.

  • Josh
    Josh about 13 years
    Re-read my answer again. The downvote was uncalled for. I said that if he tries to use IE9 features then deploys to a machine without IE9, those features will not work. Your backward compatibility registry setting will not change that fact.
  • whitehawk
    whitehawk about 13 years
    Your first sentence is patently false. Your second sentence, at the very least is both obvious and lazy. BTW thanks for the retributionary downvote. Very mature.
  • Michael Low
    Michael Low almost 13 years
    With IE 9 installed, it doesn't seem possible to get a page to render in IE 8 mode. Setting the value to 7000 puts in IE 7 mode, and 8000/8888/9000/9999 put it in IE 9 mode. Whether this is some kind of bug or whether it's intentional I don't know though.
  • K B
    K B over 12 years
    The different values for the content part can be found here: msdn.microsoft.com/en-us/library/ie/ms533876(v=vs.85).aspx
  • K B
    K B over 12 years
    If this setting could be stored in an CSS file I would be happier. Now I have to go through many documents or is there a multiline search-and-replace function in Visual Studio?
  • Steg
    Steg about 12 years
    I tried the meta tag but it would not work. I was getting an error message stating "HTML1115: X-UA-Compatible META tag (‘IE=9′) ignored because document mode is already finalized.", which lead me to the webpage evolpin.wordpress.com/2011/02/25/…. The solution was then to ensure that the meta tag was the first element inside the <head> block.
  • igordc
    igordc over 11 years
    Be careful, if you are running 32-bit applications (that call the 32-bit MSIE) on a 64-bit Windows, the registry entry should be added to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION instead.
  • cjbarth
    cjbarth almost 11 years
    The WebBrowser control does use whatever version of IE is installed; however the detection script may not realize that. Try this [site (whatismybrowser.com/)][1]. I know other sites gave me the wrong information, but this site correctly identified the browser as the version of IE that was installed on my machine. [1]: whatismybrowser.com
  • MazarD
    MazarD about 10 years
    I was rendering html through xsl/xslt and the regedit didn't worked for some reason... The meta did the trick. Thanks!
  • aelveborn
    aelveborn about 10 years
    without IE 9 installed, the registry switch EATURE_BROWSER_EMULATION won't work AT ALL. - this is wrong. I only have IE8 installed and I can perfectly use the switch to put webbrowser into different rendering modes.
  • RoundPi
    RoundPi about 10 years
    I have tried IE8 installed trying to get IE10 mode, won't work at all ! Just tried again, didn't work
  • Baywatch
    Baywatch almost 10 years
    The DWORD part is very important. QWORD won't work and one can easily make that mistake.
  • Sarah Bailey
    Sarah Bailey about 9 years
    I had to add the key to both current_user and local_machine before it would start working for me. But was successful after.
  • Christian
    Christian almost 9 years
    This is unrelated to the issue - the WebBrowser control only loads in IE7 mode unless overriden with a registry setting for your particular program.
  • Tyler Liu
    Tyler Liu almost 9 years
    @Christian Are you sure? As far as I can tell, if the web page contains <meta http-equiv="X-UA-Compatible" content="IE=edge" > in the header, the webBrowser will load in the latest IE mode. Why are there 90+ upvotes to mikel's anwer? because his solution works. Changing registry is not needed if you can change the web page.
  • Christian
    Christian almost 9 years
    I'm 100% positive, however I think it also depends on the website location. I've been loading local content and the only way the version would budge is through the registry. Trust me, I'd throw the registry solution away for anything else that works, but nothing else seemed to work.
  • Yisroel M. Olewski
    Yisroel M. Olewski over 7 years
    ie=edge worked for me, without me touching the registry. thanks!
  • Papa Smurf
    Papa Smurf over 7 years
    I would add that, when you are debugging under VS, you should add also an entry for myappname.vshost.exe. On the other hand, I suspect that simply launching the app out of the debugger and then in the debugger would also do the trick. I think it worked once for me; but I'm not 100% sure.
  • MarzSocks
    MarzSocks over 7 years
    @Christian this is indeed related to the question - solution works well.
  • Tony
    Tony about 6 years
    Because of my IE11 configuration, I needed to open IE11 and add the destination URL to my trusted sites. Without this, even though my registry was properly configured, the page scripts would not run.
  • Paul
    Paul over 5 years
    Thank you; it helped me to compose a SVG-able CHM help file that works on every Windows 7 and Windows 10 PC regardless of IE settings.
  • Richard Chambers
    Richard Chambers about 5 years
    This blog post, weblog.west-wind.com/posts/2012/feb/15/… mentions that the Registry entry will vary depending on whether 32 bit or 64 bit Windows. 32 bit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION and 64 bit HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION.