I recently needed to use a webbrowser control with an Outlook plugin – in order to display information hosted in a web application. The big problem is that by default, the .Net browser control emulates Internet Explorer 7. This is a big issue for web developers who want to create nice looking information for the browser control – and use the latest techniques. Regardless of which.net framework I used, the browser control was emulating IE 7 (seriously ?) So the poor web developers working with me had a hard time trying to support IE7.
I discovered you can force (emulate) a preferred Internet Explorer version using a simple registry mod. You can check this MSDN article for more information on how to do this. The best thing to notice is you don’t need admin rights for this.
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER) SOFTWARE Microsoft Internet Explorer Main FeatureControl FEATURE_BROWSER_EMULATION yourapp.exe = (DWORD) 00009000
Since my code is required to run as an outlook plugin, the application runs inside outlook. So I can’t use yourapp.exe, I always have to use outlook.exe if I want this done inside an outlook plugin. I started writing some code to do the this registry mod.
Microsoft.Win32.Registry.SetValue(@"HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMainFeatureControlFEATURE_BROWSER_EMULATION", appName, ieVer)
You can find the IE version by using this table
Value | Description |
11001 (0x2AF9 | Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the !DOCTYPE directive. |
11000 (0x2AF8) | IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11. |
10001 (0x2711) | Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive. |
10000 (0x02710) | Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10. |
9999 (0x270F) | Windows 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. Default value for Internet Explorer 9.Important In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards 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. Default value for Internet Explorer 8Important In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. |
7000 (0x1B58) | Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control. |
I initially ran this code inside my outlook plugin but it didn’t give me what I actually want. When Outlook loads for the first time it checks the registry for this value and decides whether to use IE7 or not. So, doing the modification inside the application will only affect the version used once the application has restarted. I solved the problem by writing a custom action in the installer.
When researching this solution I came across this awesome website which tells you the current browser version. Of course you can write your own script to find this out.