WebBrowser relationship with IE, how to set WebBrowser work in IE9, 10, 11 mode?

Source: Internet
Author: User

Web Browser control–specifying the IE Version
Http://www.west-wind.com/weblog/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version

I Use the Internet Explorer Web Browser Control in a lot of my applications to display document type layout. HTML happens to is one of the most common document formats and displaying data in this format–even in desktop Applicatio NS, is often-easier than using normal desktop technologies.

One issue the Web Browser Control has this it ' s perpetually stuck in IE 7 rendering mode by default. Even though IE 8 and now 9 has significantly upgraded the IE rendering engine to being more CSS and HTML compliant by Defaul t the Web Browser control would have none of it. IE 9 in Particular–with it much improved CSS support and basic HTML 5 support is a big improvement and even though the IE control uses some of IE ' s internal rendering technology it ' s still stuck in the old IE 7 rendering by default.

This applies whether your ' re using the Web Browser control in a WPF application, a WinForms app, a FoxPro or VB classic app Lication using the ActiveX control. Behind The scenes all these UI platforms use of the COM interfaces and so your ' re stuck by those same rules.

Feature Delegation via Registry Hacks

Fortunately starting with the Internet Explore 8 and later there ' s a fix for this problem via a registry setting. You can specify a registry key to specify which rendering mode and version of IE should is used by that application. These is not global mind You–they has to is enabled for each application individually by writing a Registry V Alue for each specific EXE, which is hosting the WebBrowser control.

This setting can is made for all users on local machine registry key or Per user in the current user key of the registry.

For the current User:

I ' d recommend using the current user setting, as this setting can is made in one place and doesn ' t require admin rights to Write to the registry. This means you can actually make the change from within your application even if you don ' t use an installer or run under An Admin account.

Your do has to restart the app to see the change.

The key to write to is:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\main\featurecontrol\feature_browser_emulation

Value Key:dword YourApplication.exe

Note that the featurecontrol and feature_browser_emulation keys could not be exist at all prior to Installati On whole branch. "

For all Users:

There is different sets of the keys for the + bit and the applications.

A-bit or a-bit only machine:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\main\featurecontrol\feature_browser_emulation

Value Key:dword- YourApplication.exe

On the bit machine:

Hkey_local_machine\software\wow6432node\microsoft\internet Explorer\main\featurecontrol\feature_browser_ EMULATION

Value Key:dword YourApplication.exe

The value to set this key to be (taken from MSDN here) as decimal values:regi

11001 (0X2EDF)
Internet Explorer 11. Webpages is displayed in IE11 standards mode, regardless of the! DOCTYPE directive.

11000 (0X2AF8)
Internet Explorer 11. Webpages containing standards-based! DOCTYPE directives is displayed in IE9 mode.

10001 (0X2AF7)
Internet Explorer 10. Webpages is displayed in IE10 standards mode, regardless of the! DOCTYPE directive.

10000 (0x2710)
Internet Explorer 10. Webpages containing standards-based! DOCTYPE directives is displayed in IE9 mode.

9999 (0x270f)
Internet Explorer 9. Webpages is displayed in IE9 standards mode, regardless of the! DOCTYPE directive.

9000 (0x2328)
Internet Explorer 9. Webpages containing standards-based! DOCTYPE directives is displayed in IE9 mode.

8888 (0X22B8)
Webpages is displayed in IE8 standards mode, regardless of the! DOCTYPE directive.

8000 (0X1F40)
Webpages containing standards-based! DOCTYPE directives is displayed in IE8 mode.

7000 (0x1b58)
Webpages containing standards-based! DOCTYPE directives is displayed in IE7 standards mode.

The added key looks something like this in the Registry Editor:

Note that the settings is significant depending on the type of application is running. If you are running a, application on a, the Wow6432node key to register this setting. If you ' re running a with a application on a + bit machine, or a bit of application on a for a bit application, then the Standa  RD registry key should be used. This means if you ' re installing a + application using an installer you probably would want to set both the WOW64 key A nd the regular key on the machine.

With the place my HTML Help Builder application which have Wwhelp.exe as its main executable now works with Html 5 and CSS 3 documents in the same to that Internet Explorer 9 does.

Incidentally I accidentally added an ' empty ' DWORD value of 0 to my EXE name and so worked as well giving me IE 9 render Ing. Although not documented I suspect 0 (or an invalid value) would default to the installed browser. Don ' t have a good-to-test this and if somebody could try this with IE 8 installed the would be great:

    • What happens when setting 9000 with IE 8 installed?
    • What happens when setting 0 with IE 8 installed?
Don ' t forget to add Keys for Host environments

If you ' re developing your application in Visual Studio and you run the debugger you'll find that your application is stil L not rendering right, but if you run the actual generated EXE from Explorer or the OS command prompt it works. That's because when you run the debugger in Visual Studio it wraps your application into a debugging host container. For the reason might want to also add another registry key for Yourapp.vshost.exe on your development machin E.

If you ' re developing in Visual FoxPro make sure you add a key for Vfp9.exe to see the rendering adjustments in th e Visual FoxPro development environment.

WebBrowser relationship with IE, how to set WebBrowser work in IE9, 10, 11 mode?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.