Web Browser Control & Specifying the IE Version
updated Aug 26th, 2016 - the original was published in May 2011
I use the Internet Explorer Web Browser Control in a lot of my desktop applications to display document content. For example Markdown Monster, Help Builder and WebSurge rely heavily on the Web Browser Control to render their document centric or even rich interactive UI (in the case of Markdown Monster which hosts an HTML editor). Whether you're just rendering document content, or you're interacting with rich interactive content, HTML happens to be one of the most common document formats to display or interact with and it makes a wonderful addition to conventional forms based UI. Even in desktop applications, is often way easier than using labels or edit boxes or even some of the WPF text containers. HTML is easy to generate, generally re-usable, and easily extensible and distributable. The Web Browser Control allows for an effective way to display HTML in your applications in a way that blends in and becomes part of your application.
But there's a snag: The Web Browser Control is - by default - perpetually stuck in IE 7 rendering mode. Even though we're now up to IE 11 and a reasonably HTML5 compatible browser, the Web Browser Control always uses the IE 7 rendering engine by default. This is because the original versions of the ActiveX control used this mode and for backwards compatibility the Control continues this outdated and very HTML5 unfriendly default.
This applies whether you’re using the Web Browser control in a WPF application, a WinForms app, or FoxPro application using the ActiveX control. Behind the scenes all these UI platforms use the same COM interfaces and so you’re stuck with those same rules.
The good news is there are a couple of ways to override the default rendering behavior:
- Using the IE
X-UA-CompatibleMeta header - Using Application specific
FEATURE_BROWSER_EMULATIONRegistry Keys
But first lets see the problem more graphically.
Rendering Challenged
To see what I’m talking about, here are two screen shots rendering an HTML5 page that includes some CSS3 functionality – rounded corners and border shadows - from an earlier post. One uses Internet Explorer as a standalone browser, and one uses a simple WPF form that includes the Web Browser control.
Full IE Browser:
Web Browser Control in a WPF form:
The the full Internet Explorer the page displays the HTML correctly – you see the rounded corners and shadow displayed. Obviously the latter rendering using the Web Browser control in a WPF application is a bit lacking. Not only are the new CSS features missing but the page also renders in Internet Explorer’s quirks mode so all the margins, padding etc. behave differently by default, even though there’s a CSS reset applied on this page. But the default IE 7 mode doesn't recognize many of these settings resulting in a terrible render mode.
If you’re building an application that intends to use the Web Browser control for a live preview of some HTML this is clearly undesirable.
Using the X-UA-Compatible HTML Meta Tag
If you control the content in your Web Browser control by rendering the HTML pages you display yourself, the easiest way to provide later versions of the IE rendering engine is by using the IE Edge mode header. By adding a meta tag to the head of the HTML document rendered in the Web Browser Control you can effectively override the IE Rendering engine and specify which version of IE (or the latest version) to use.
The tag to use in the header looks like this:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Inside of a full document it looks like this:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
... other headers
</head>
<body>
... content
</body>
</html>
Note the header should be the first header so that the engine is applied before any other headers are processed.
In this case IE=edge uses the current version of IE that is installed on the machine. So if you have IE 11 installed that's used, if IE 10 is installed that's used.
You can also specify a specific version of IE:
<meta http-equiv="X-UA-Compatible" content="IE=10" />
For info on all the modes available see this StackOverflow answer.
Alternately you can also serve X-UA-Compatible: IE=edge as a raw HTTP header from a Web server, which has the same behavior as the http-equiv meta header.
Caveats with the Edge Mode Header
There are a few things you need in order to use the meta tag and make it work properly:
You have to control the Page
In order to add the<meta>tag you have to control the page so that you can add the<meta>tag into your HTML. If you're rendering arbitrary HTML that doesn't include the tag, then this approach won't work obviously. Typically the header approach works great if you generate your own content.Browser Version Reporting is incorrect
The<meta>tag changes the rendering engine behavior that IE uses, but it doesn't change the way that IE reports its version. If you access pages that do IE version checking you'll find that it still points at IE 7 (or sometime some custom browser version) that doesn't reflect the current rendering mode. If you're running script code that may rely on browser sniffing this can become a problem. I ran into this recently with Ace Editor, which has a couple of odd places where it uses browser sniffing for dealing with the clipboard, and that code wouldn't work. This is likely an edge (ha ha) case, but be aware that this can become a problem.
Feature Delegation via Registry Hacks
Another and perhaps more robust way to affect the Web Browser Control version is by using FEATURE_BROWSER_EMULATION. Starting with IE 8 Microsoft introduced registry entries that control browser behavior when a Web Browser Control is embedded into other applications. These registry values are used by many application on your system.
Essentially you can specify a registry with the name of your Executable and specify the version of IE that you would like to load. The numbers are specified as 11000, 10000, 9000, 8000 and 7000. The keys can be specified either for the current user (HKCU) or globally for all users (HKLM).
Here's what I have in my HKCU key:

Notice some big applications like Visual Studio and Outlook use these overrides and at the HKLM keys you will also find apps like Skype SnagIt, Fiddler, SourceTree, 1Password and the Windows Help Viewer to name a few. So this feature is actually used by a wide range of popular software.
Registry Key Location for FEATURE_BROWSER EMULATION
You can specify these keys in the registry at:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
The HKCU key is the best place to set these values because there's a single key and it can be set without admin rights, but you can also set these keys at the machine level at HKLM:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
or for a 32 bit application on a 64 bit machine:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
Key Name
The keyname is the EXE name of your application like:
- outlook.exe
- MarkdownMonster.exe
Values
The value specifies the IE version as follows:
The value to set this key to is (taken from MSDN here) as decimal values:
11001 (0x2AF9)
Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive.
11000 (0x2AF8)
Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 mode.
10001 (0x2AF7)
Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
10000 (0x2710)
Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 mode.
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. This mode is kind of pointless since it's the default.
Setting these keys enables your applications to use the latest Internet Explorer versions on your machine easily. Unfortunately there doesn't seem to be a key that says use the latest version that's installed - you have to be specific regarding the version unfortunately. Given that Windows 7 and later can run IE 11, I'm requiring users to have IE 11 if I want to use HTML5 and more advanced CSS features like Flexbox, but if your content is simpler you can probably get away with using IE 10 or even IE 9.
Don’t forget to add Keys for Host Environments
As mentioned above you have to specify the name of the EXE you're running as the key in the registry.
If you're using a development environment like Visual Studio or Visual FoxPro to debug your applications, keep in mind that your main EXE you are running while debugging may not be the final EXE that you are building. So after you've set up your registry keys, your debugging experience may still not see the enhanced rendering features in the Web Browser control because you're not actually running the final EXE.
The problem is that when you debug in these environments, you are running a debugging host and in order for it to render properly you may have to the host to the FEATURE_BROWSER_EMULATION keys as well.
For Visual Studio this will be yourapp.vshost.exe, which is the debugging host. For Visual FoxPro you'll want vfp9.exe. Simply add these keys to the registry alongside those you use for your actual, live application.
Registry Key Installation for your Application
It’s important to remember that the registry settings from above are made per application, so most likely this is something you want to set up with your installer. I let my installers write the values into the registry during the install process which also removes the keys on uninstall.
Personally I always prefer setting this value per user using using the HKCU key which works for both 32 and 64 bit applications in one place.
If you set the keys globally on HKLM for all users, remember that 32 and 64 bit settings require separate settings in the registry. So if you’re creating your installer you most likely will want to set both keys in the registry preemptively for your application.
Installation
As an example, I use InnoSetup for just about all of my installs now which looks like this:
; IE 11 mode
Root: HKCU; Subkey: "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"; ValueType: dword; ValueName: "MarkdownMonster.exe"; ValueData: "11001"; Flags: createvalueifdoesntexist
Other installer products will also let you install keys directly.
Note that if you use the HKEY_LOCAL_MACHINE key you can also add the registry keys directly as part of your application when it starts up.
The following is .NET code, but it should give you an idea how to easily create the keys:
public static void EnsureBrowserEmulationEnabled(string exename = "MarkdownMonster.exe", bool uninstall = false)
{
try
{
using (
var rk = Registry.CurrentUser.OpenSubKey(
@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true)
)
{
if (!uninstall)
{
dynamic value = rk.GetValue(exename);
if (value == null)
rk.SetValue(exename, (uint)11001, RegistryValueKind.DWord);
}
else
rk.DeleteValue(exename);
}
}
catch
{
}
}
Summary
It would be nice if the Web Browser Control would just use the native Internet Explorer engine as is, but as you see in this article, that's unfortunately not the case and you have to coerce the browser. If you have control over your documents that you render in the Web Browser Control you may be able to use X-UA-Compatible header in your pages. Otherwise you have to resort to the registry hack using FEATURE_BROWSER_EMULATION.
Personally I've used the registry hack for all of my apps that use the Web Browser Control because my applications tend to render HTML from all sorts of different sources - local generated content, as well as Web loaded pages for previews and sometimes even dynamically injected content. It's better to force the latest IE version for all content than forget the fact you need custom headers for other non-application content you might display (update notices, registration forms, notifications etc.)
These days most machines will be running either IE 10 or 11, so there's much less of a problem with differening browser behavior than there used to be.
The Voices of Reason
# re: Web Browser Control – Specifying the IE Version
Thank You,
Vish
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
I added this DWORD Key :
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
with :
key name = vfp9.exe Decimal value = 8000
But nothing happends.
note : this css menu works well inder win7+IE11
Needs helps
thinks
# re: Web Browser Control – Specifying the IE Version
I'm using ie10 in windows 7 and 270f hex worked for me.
Thanks!
# re: Web Browser Control – Specifying the IE Version
Excellent post - many thanks.
It is a little hard to understand why the WebBrowser control does not default to using the highest version of IE installed but I suspect people much brighter than I have a defensible reason.
Kind Regards
Mark
# re: Web Browser Control – Specifying the IE Version
By specifying the version in the registry you tie an application to a specific version (although you still have to deal with downlevel support for older browser installs - yuk).
Incidentally this version switching scheme is an excellent way to let you test operation under various versions of IE :-) You can have an app hosted in the Web Browser control and manually (or via code) switch the registry values to use a different version of IE.
# re: Web Browser Control – Specifying the IE Version
Thanks!
Andrew
# re: Web Browser Control & Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
I'm running a windows service to render a HTML content on WebBrowserCotrol and take the screenShot of the output and save it in the specified local directory. I'm able to achieve this if i'm logged in the server, if I'm logged out of the server I'm getting the script error. I think it still try to find the registry entry in the HKEY_CURRENT_USER
I have tried all the below option
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Any idea on this?
Regards,
Govind
# re: Web Browser Control – Specifying the IE Version
There should at least be a property we can set to enable this, without having to elevate and hack the HKLM hive of the registry!
As for having multiple settings for the same exe name, what if two vendors produce applications with the same executable name? Vendor A wants their "helper.exe" to use IE9, and Vendor B wants their "helper.exe" to use IE7. With the current system, there's no way to have both applications working on the same PC at the same time.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
All I'm saying is, we should be able to have this level of functionality within our own applications, without having to hack the registry. As it stands, Chromium is looking like the better option. :)
# re: Web Browser Control – Specifying the IE Version
If there's another way I'd love to know about it. I would love to make this user selectable with a switch so they can determine what they see! Especially given IE 9's mungled ClearType only rendering that can't be turned off and which drives me nuts (and is the main reason I don't use IE 9).
# re: Web Browser Control – Specifying the IE Version
How do you do this for VFP?
I added an entry in the registry :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
vfp9.exe with dword = 9000
However even simple pages do not display and there are javascript errors.
If I add the meta tag :
<meta http-equiv="X-UA-Compatible" content="IE=9" >
then the page renders correctly.
So my Q is how can I test a form using HTML5 in the VFP9 ide - what is the registry setting that works?
Thanks
# re: Web Browser Control – Specifying the IE Version
Sorry to bother again. Its worked by adding my application name (vfp9.exe) but thing is fish tank is not working as smooth as its in ie9. Any specific reason ?
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
Make sure you set both 32 bit and 64 bit keys if you're running on Windows 7 so settings apply to both versions of IE (if you install the 64 bit version often the 32 bit version runs anyway especially via COM automation).
Also remember that VFP9.exe only works when you're running in the FoxPro environment. For your own app you have to add another key for the actual EXE name in the registry.
It's easy to check whether IE9 or classic rendering is used - go to a page that use CSS 3 features like the one I showed above:
http://www.west-wind.com/WestwindWebToolkit/samples/ajax/Html5AndCss3/RoundedCornersAndShadows.htm
# re: Web Browser Control – Specifying the IE Version
This entry has been incredibly useful in resolving some issues I've been having with using the browser control under Win7 and IE11. I've played with all the indicated values and find 270F, 2AF9, 2711 work the best so far. Outstanding is that somewhere deep in the bowels I get a dialog box "Message from webpage" "Client side XSL transformations are not supported on your browser". The message does not occur from a desktop browser. I've done a few searches and can't find anything to help. Would you have any pointers on how to resolve this?
Thanks
Ken
# re: Web Browser Control – Specifying the IE Version
and rick i m not doing anything inside vfp just opening fishtank sample of ie9.
# re: Web Browser Control – Specifying the IE Version
thanks, Lambert
# re: Web Browser Control & Specifying the IE Version
Well done Rick, thank you ! It was just for a personal project (automating collection of my smart-meter daily half-hour usage data, for which my electricity provider has so far failed to produce a simple downloadable .csv file. However, a text listing for each daily set of data is available about 15-clicks-down following login...) Oh great... so I have to do it the hard way by automation via the VB dot net WB - but initially the pages were incorrectly rendered and presented in a total mess. Your article, 15 minutes, including a built-in reg check at program start-up in case I ever migrate the program to another machine and forget what to do - Problem Solved !!! Thanks again, Bill 😃
# re: Web Browser Control – Specifying the IE Version
But what about if using a dll instead of a .exe ?
What value should have then key ? example.dll ? example ? c:\mypath\example.dll ?
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
So there's no way for me :( I'm using a .net component to get screen captures of websites for my directory and it seems it uses the rendering engine of... IE6 (websnapshots from Tonec)
If one day i find how to, i'll post the answer there ;)
# re: Web Browser Control – Specifying the IE Version
Your post has saved me a lot of pain.
Here's why:
My html form that renders within my web browser control relies on the following button tag:
<button style="font-size:smaller" type="submit" name="buttonAction" value="AddSelectedProducts">Go</button>
My MVC controller code relies on the VALUE of the "buttonAction" parameter in order to process the request appropriately.
Here's the problem: IE 7 does not submit the actual button's value ("AddSelectedProducts") and instead submits whatever text is in between the button tags (in this case: "Go").
The correct behavior only appears in IE 8 and above. Your registry hack now forces my web browser control to act as expected and submit the correct value for the button.
This varying "button" behavior is noted at: http://www.w3schools.com/tags/att_button_value.asp (scroll down to where it says: "Definition and Usage")
Note: even though the w3schools spec states that this undesired behavior occurs prior to IE9, my tests show that it occurs prior to IE8. Thankfully so, since my clients are all Win XP users and not Win 7.
Cheers and many thanks,
AB
# re: Web Browser Control & Specifying the IE Version
Does this work when your program is MFC based and using the CHtmlView class?
Do you have to reboot after changing the keys?
# re: Web Browser Control & Specifying the IE Version
Hello Rick,
I have a 32 bit MFC application running on 64 bit Windows 7. Application has web browser in which we view Google maps(poly.js error Issue 10310 at google developer forum), After changing in the registry or meta tag it does not work for me.
Any suggestion??
# re: Web Browser Control – Specifying the IE Version
I have added Registry key to HKEY_CURRENT_USER and Wow6432Node folder and script error problem is resolved. Thanks a lot for this nice post.
But now HTML is not rendering properly. Any specific reason? This is a production issue and need to be fixed ASAP. DocType is XHTML 1.0 Transitional.
# re: Web Browser Control & Specifying the IE Version
Harshith, are you sure the issue is the browser version and not an issue with your javascript code potentially? The best way to check is to add some HTML5/CSS3 code to the page you're testing and see if it renders those pieces. Also make very sure that your EXE file matches what you are running and make sure it goes into the right registry location. I prefer using the HKCU because it'll work regardless whether it's 32 or 64 bit.
# re: Web Browser Control – Specifying the IE Version
<h1>Opt-In to High DPI Behavior for Web Browser Controls (WebOCs)</h1> <span>In order to preserve compatibility with previously developed WebOCs, by default Internet Explorer 8 does not render the web content of WebOCs using the Internet Explorer 8 High DPI behavior, but rather uses the Internet Explorer 7 behavior, which scales up fonts specified in absolute values, such as points. To take advantage of the Internet Explorer 8 High DPI behavior in your programs, you need to use a DOCHOSTUIFLAG called DOCHOSTUIFLAG_DPI_AWARE. You use this flag by using the method GetHostInfo, which has a DOCHOSTUIINFO structure as one of its parameters. In turn, DOCHOSTUIINFO has a operator DWORD called dwFlags as one of its members, that can consist of one or more DOCHOSTUIFLAG values. You must include DOCHOSTUIFLAG_DPI_AWARE in dwFlags in order to take advantage of the Internet Explorer 8 High DPI behavior in your WebOC.</span><br /><br /> <span>The quick and easy way to simulate how the HTML content of your WebOCs will appear once opted -in to the High -DPI behavior is to open the equivalent HTML content (composed in an HTML file) in Internet Explorer 8, and simply check out the rendering at the equivalent zoom settings (120 DPI to 125% zoom, 144 DPI to 150% zoom). We do recommend that you test out the WebOC in actual High DPI scenarios to be completely sure the HTML content renders as you hoped.</span><br /><br />
here: http://msdn.microsoft.com/en-us/library/ie/cc849094(v=vs.85).aspx
Is there one of those flags to switch co IE8 as well?
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
We have a 32 Bit MFC(MDI) application developed from Visual Studio. It runs on 64 Bit Windows 7.
We have a Web Browser control derived from CHTMLView, which used to load google maps.
As we by default Browser control has IE 7 settings I used to get a pop up error called poly.js (https://code.google.com/p/gmaps-api-issues/issues/detail?id=10310) in order to resolve this we had two options
Registry hacks using FEATURE_BROWSER_EMULATION which did not work for me.
this used to give access denied error because i had jquery version 1.4.2 which is very old.
The problem come here , after this access denied error i updated the jquery version to latest 3.1.0 and i dont get any error but i see WHITE BLANK SCREEN!!! this is the issue i am facing when i load googles maps through the MFC Browser.
How to resolve this issue?? i have tried many workarounds but no luck.
Is there any way to update browser control default rendering version from IE7 to IE 10/11 or Edge?
This has become a nightmare for us!! please help to resolve this issue.
# re: Web Browser Control & Specifying the IE Version
Hello Rick,
Thanks for your reply.
Yes, the problem is because of browser version. Till May 2016 we had mete tag as and jquery version 1.4.2 ,jquerry-ui version 1.8.4 and we used to load the maps there we had no pronlem at all!!
But after Google Maps API version updated to 3.25 we are getting popup error poly.js(only for Google maps customized with polylines)
I tried changing meta tag to 10/11 or Edge it was showing access denied error because of oudated jquery version 1.4.2 so i update to latest 3.1.0 or 3.1.1. I was not getting Access denied error but map wasn't loading just a WHITE BLANK SCREEN!!
2.I added the DWORD at HKCU/HKLM with same EXE name as displayed in task manager.But i did not see any effect of this.
# re: Web Browser Control – Specifying the IE Version
I've played with various settings but still end up with some problems. The application targeting runs fine in a desktop browser that has the enterprise mode set on. Is there some way I can set Enterprise mode for what runs in the library
Thanks
Ken
# re: Web Browser Control – Specifying the IE Version
With IE11 now installed i've had to change my value from 8000 to 8888. I was getting OLE errors in IE11 when doing createRange() and trying to access the nodeName or tagName of the parentElement. Changing the value to 8888 solved it. I don't use 9000 or 9999 or higher, since i need to make sure my webbrowser control works in IE8 still. I use the webbrowser control as an Html editor also.
Also, Microsoft has updated the list of valid values to add IE10 and IE11 at the website link Rick provided in the article above.
Again, Rick this article has been enormously helpful. Many Mahalo's!
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
And Role, thanks so much for your post on the FEATURE_USE_LEGACY_JSCRIPT. That solved the createRange() issue.
# Using DesignMode="On" with ie9
<input style="width: 100px; height: 22px;" name="edtbox" value="test" size="23">
If I change the text in the <input> control from "test" to something else by typing inside the text box, IE behaves differently. With contentEditable=.t., IE *does not* update the "value" attribute of the input element. If using DesignMode="On" IE *does* update the "value" attribute. This is important for me, since it allows users to specify the default value of an input element in wysiwyg mode. (they can design documents with fill-in fields).
The only problem I am experiencing using DesignMode="On" (with a !DOCTYPE of HTML 4.01), is that the WebBrowser control *always* displays the Horizontal scrollbar regardless of the content in your document. It appears that the rightmose side of the document's content always goes underneath the Vertical scrollbar. This happens no matter how wide your control or content is. It seems to be a bug in the control. It's not recognizing the bounds of the vertical scrollbar. This does not happen in ie7 mode.
It's more of an issue if you have a block element of 100% width for example, with borders displayed. The right-most side of the block element will always display underneath the vertical scroll bar, no matter what you do. If anyone is able to resolve this, please reply.
Another reason I prefer DesignMode="On" is that you can right-click in the control and select "View Source". You can't do that with contentEditable=.t.
TIA if anyone can shed light on this probable bug.
# DOCTYPE of HTML 4.01 or higher issues with WB ctrl
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
there's an issue when resizing block elements.
If I resize a block element (Div, Input, etc) by dragging the handles of one dimension (width or height), it "always" increases the other dimension also. I can't figure why. It does not matter if I have the registry hack for vfp9.exe set to 9999 in BROWSER_EMULATION or not. Simply the Doctype seems to be causing this. And it doesn't matter if I'm using contentEditable=.t. or DesignMode="On". If I remove the Doctype declaration it doesn't have this issue but of course reverts back to ugly html. I guess the WB control is problematic for editing when specifying a Doctype, regardless if the hack is set for ie9 or not. Anyone else expreriencing this.
# re: Web Browser Control – Specifying the IE Version
Rick - you da man! Thank you for posting this!
# re: Web Browser Control – Specifying the IE Version
Thank you for the info. I have a 64 bit Windows 7 machine that does not have the "Wow6432Node" key, so I used the 32bit path and it worked like a charm. Could there be something else that is causing you to use the "Wow6432Node" key? Possibly an enterprise version of Windows?
Also, there appears to be a meta tag, <meta http-equiv="X-UA-Compatible" content="IE=edge">, that can be placed in the webpage itself that is supposed to force the control to use the latest version of ie for the rendering. I haven't tried it, and can't find the page again in msdn.com :(. but thought you would like to know.
# re: Web Browser Control – Specifying the IE Version
I tried the meta header, but that only affects the rendering style once the browser is loaded. For me that alone didn't work.
# re: Web Browser Control – Specifying the IE Version
Great Post..Thanks a lot...
But small issue......
I created a new class to specify the IE version in registry as Machine or Current User.But first time my application not working,second time its working fine...Any update or refresh command required for Webbrowser Control.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
I was making a new Windows Forms app which make use of WebBrowser control.
(I run this app elevated, as I do some other things with IIS and need admin rights)
When I try to add my executable to both HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION and HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION registry keys, it only gets registered at the Wow6432Node key?
But if I programmatically check if key exists, it says both are there?
Even if I force to write to both places it still, when you look manually, appears only at Wow6432Node but when check with the program it says it exists in both places??
# re: Web Browser Control – Specifying the IE Version
Found answer, when executable is compiled targeting x64 it writes to both registry keys, but when it is compiled to 'any' or x86, it only writes to the Wow6432Node key.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
Thank you for the information.
Solved a problem with a 'position: fixed' element, which wasn't displayed before I added the registry entry.
# re: Web Browser Control & Specifying the IE Version
Harshith, the registry keys should most definitely work. Make sure you are specifying the right EXE process that is hosting your control. For example, when running from Visual Studio you maybe hosting inside the Debug Host container rather than your EXE. Check task manager if in doubt.
# re: Web Browser Control – Specifying the IE Version
I ended up with these settings which seems to work with Win10 and use the latest IE11 engine:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"App.exe"=dword:00002af9
"App.vshost.exe"=dword:00002af9
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]
"App.exe"=dword:00002af9
"App.vshost.exe"=dword:00002af9
Thanks also to this blogpost here: https://kevinragsdale.net/windows-10-and-the-web-browser-control/
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
>> What happens when setting 0 with IE 8 installed?
Here is my test results for user-agent value, Im using Delphi app (32bit) and IE WebBrowser ocx.
WinXP (32bit), IE8.0.6001.18702, testapp.exe (32bit)
regval 9000 = Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)
regval 0 = same user-agent as 9000 value
Win7 (64bit), IE9.0.8112.16421, testapp.exe (32bit)
regval 9000 = Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
regval 0 = same user-agent as 9000 value
I am going to use regval 0 for all application deployments, it switches to the any highest mode available in a users machine. Application can automatically update HKEY_CURRENT_USER registry tree for itself avoiding any privilege issues.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
The main problem I'm trying to solve, is how to SWITCH modes at run-time (like IE developer tools does).
My application itself (not the installer) updates the registry as done by @Asdf (since I write to HKCU there is no UAC issue). I'm also using Delphi btw.
But the problem is how to refresh/reload the WB control and tell it that the registry setting were changed... It seems that the key value is read by the FIRST instance of the WB control that was created by the application. so even, If you destroy the control, change reg value , and create a new instance, the old value is preserved until you restart your application.
Maybe there is an Exec command for this, or a special message?
Any ideas?
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
The registry hacks just solved my problem.
I have answered myself question on stackoverflow with reference to this page.
http://stackoverflow.com/questions/33098335/only-white-color-with-zoom-control-shown-in-google-maps-div-area/33108011#33108011
# re: Web Browser Control – Specifying the IE Version
that is just what I want. It works and save a lot of time for me.
Thx a lot.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
thanks for many informative articles over the years, in particular really enjoyed working with your RazorHosting Engine - excellent.
Ok, back to the subject. I've in the past gone with adding:
<meta http-equiv="X-UA-Compatible" content="IE=9" >
I've also made sure that the doctype is:
<!DOCTYPE html>
with the caveat that IE9 has to be installed on the host machine. this has been mainly fine for me as this has been used mainly on intranets where the environment is known, or in conjunction with your RazorHosting engine.
Thanks again
jim
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
I can confirm that under WinXP with IE8, a DWORD value of 0 (zero) will pick IE8, thus seeming to confirm your "invalid value determines default browser" theory.
Only tested on one machine. YMMV.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
I'd like to review the statement. Using wb.Navitage("http://someurl...") works fine for 9000 as well. And there are all linebreaks for 11000.
How do I achive the same for wb.Navigate("about:blank") and wb.Document.Write(<!DOCTYPE><html><head></head><body>" & txtText.Text & "</body></html>") ? It seems that the document mode is not loaded properly in this scenario.
# re: Web Browser Control – Specifying the IE Version
@Pavel - if you need to load a full page I recommend you write a file to disk then navigate to disk. You can then apply the appropriate DOCTYPE to the document that's on disk.
# re: Web Browser Control – Specifying the IE Version
about:blank is the problem! Using different about:xxxxxxx causes the document to load in different mode.
about:navigationcanceled as initial navigation worked fine for me.
Thank you
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
Thanks!
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
Just one CORRECTION:
You mentioned the registry key value "11001 (0x2EDF)", but it should be "11001 (0x2AF9)" instead!
I stumbled on this error while testing this feature inside an app using WebBrowser Control — decimal and hex didn't add up, so I realized it was a typo.
It really works smoothly. Before this hack, I could only use IE4 HTML4 in my apps using the WebBrowser Control... but tweaking the registry as adviced here, resulted in HTML5 + CSS3 pages showing up nicely inside the WebBrowser Control!
I guess the hard part will be to now carry out all the research in order to make sure the app checks out which version of IE is present on the system. There are legion of hacks (from HTML comments to JavaScript) to do that, but most of them are intended for the web. In the context of compiled applications, the checks should be restricted to IE only. If I find a clean solution I'll paste some links/examples here...
# re: Web Browser Control – Specifying the IE Version
My Environment: VS 2010 C#, .NET 4, local IE8.
Below is my code.
In my app, java script errors dialog always be popupped, even the register key is set. But in IE8, the 2 URLs works well.
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; using Microsoft.Win32; namespace ol { public partial class Form1 : Form { public Form1() { InitializeComponent(); //RegWebBrowserIn32BitIE8Mode(); } private void RegWebBrowserIn32BitIE8Mode() { RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"); key.SetValue(Path.GetFileName(Application.ExecutablePath), 0, RegistryValueKind.DWord); key.Close(); } private void button1_Click(object sender, EventArgs e) { webBrowser1.Navigate("http://pan.baidu.com/share/link?shareid=94975&uk=673798325"); //URL1 //webBrowser1.Navigate("http://dl.dbank.com/c0wtze2ttu"); //URL2 } } }
# re: Web Browser Control – Specifying the IE Version
If you're going to muck with this - do it during the application installation, or else you have to ensure you run with elevated rights (ie. Run As Administrator).
# re: Web Browser Control – Specifying the IE Version
The code is just a sample to test.
I tryed adding the register key out of my application, in another word, I added the register key by REGEDIT application, and then ran my app, my app still had problem. The account is Administrator account.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control & Specifying the IE Version
@Andrew - not sure if CHtmlView uses IE Web Browser control but would imagine so. You don't need to reboot, but you have to restart the application.
# re: Web Browser Control – Specifying the IE Version
I am new to desktop application development and I have few questions on this topic that I hope you would be able to clarify for me. I am trying to create a simple web browser, no address bar and when the application is opened, it opens directly to a webpage I hardcoded. I am receiving javascript errors and display issues when the page is opened in the application , but not when I open the page in my IE 11 browser. I am assuming its the webbrowser using the old engine that is causing the problem?
1. In Microsoft Visual Studio Community 2015, does the WebBrower still use the IE 7 engine?
2. Would the registry hack you suggest work across Windows 7,8, 10?
3. Wouldn't MS security prevent registry updates from an application?
4. Do you have any suggestion for a different compiler that I could embed a more modern webbrowser/engine into? This would be a Windows desktop application only. No mobile, no Apple.
Thank you for your time.
# re: Web Browser Control – Specifying the IE Version
2.) Yes it works on all versions of Windows. The trick is making sure you get the right browser version - at this point go with 11001 always
3.) You can't update the HKLM registry unless you run as admin, but you can upload HKCU key from an application
4.) IE 11 is plenty 'modern' - it does a great job with just about all modern Web content
There are other engines like Awesomian and a few others, but frankly they are all very flakey on WIndows. I have several applications that use Awesonium on my Windows box and they are all broken on my Bootcamp'ed Mac because the Awesomium SDK is apparently broken. The IE control works fine. I have several products that rely heavily on browser automation (http://markdownmonster.west-wind.com/ and http://helpbuilder.west-wind.com) and these are working without problems with IE based browser controls.
# re: Web Browser Control & Specifying the IE Version
I created this basic web page that tells you what compatibility mode IE is running in: https://documentmode.000webhostapp.com
This was helpful for finding out if Rick's registry solution worked for a WPF application I have no control over. And it did, thank you Rick!
# re: Web Browser Control & Specifying the IE Version
Rick, Thanks for your help !! finally it works for me. Problem is the jQuery version which should be 1.12.4 with Edge meta tag and it also works by specifying through registry.
# re: Web Browser Control & Specifying the IE Version
Rick. Our website is currently hosted with Godaddy on a shared hosting plan. We have c# code in a background thread that uses an instance of the web browser control. I apologise for any naivety but a) do you think our code would have Access permission to change registry keys, b) we use the control to scrape our external client's websites, can we insert the edge meta tag programmatically even though the client's web pages may not have it in?
# re: Web Browser Control & Specifying the IE Version
@Mark - I'm not sure you'll have to check with GoDaddy or just try it. Permissions may not be the problem, but IIS has to be configured to allow access to a user profile. If you do have one (ie. a full user account) then you should be able to write to the Current User registry key.
You can't insert an Edge header if the page is already rendered obviously 😃 The only way you could inject is by writing an ASP.NET Module to inject it before the page is sent to the browser to render.
# re: Web Browser Control & Specifying the IE Version
Hi Rick When I set the browser to IE11 for VFP9, I lose the environment manager in the VFP task pane. Is it possible to modify the task pane so that it will work with the IE11 setting?
Thanks
# re: Web Browser Control & Specifying the IE Version
Probably not. The task pane relies on an old version of IE and unless you rebuild (there is source code) to remove those things the answer is now you can't.
Then again. Task Pane? Really? 😃
First thing I turn off in any VFP install.
+++ Rick ---
# re: Web Browser Control – Specifying the IE Version
I use PowerBuilder to create HTML pages with Google Maps Javascript which is rendered in the Microsoft Web Browser ActiveX control. It stopped working a while back. I was wading through that crazy long Google Post (9004) for hours (12) and trying everything under the sun. Nothing worked until I focused on your comments and read your blog. I changed my GM header to use v=3.24.0, installed IE 11.0 and created an entry under WOW in registry for my application.exe using hex 2AF9. Oddly, 2AF8 did not work.
Anyway, it all works now and I wanted to send my most sincere thanks for your post. Really great!!
Thanks!!
Paul
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
Nice article! However, I stumbled upon a weird use case when changing the registry keys didn't really help.
I am one of the devs for a communication tool, that among other features has an option to set up Windows screensavers. Thing is, these screensavers can contain HTML content, and I really wanted to render it in modern browser, like IE11. So I went through, added required keys and words in local_machine and current_user, adding the rules for screensaver our software generates.
The result is - if I just go on and launch the screensaver manually (by executing .scr file) - it renders in emulated IE11. If I go to screensaver settings and use the "Preview" function - it renders in emulated IE11. However, when the screensaver is launched by the system itself - it still draws all the stuff using IE7.
I was wondering if you might have any insight on what else should be changed for this to work. I tried adding usual Windows scrnsave.exe utility and our application itself to the browser emulation rules list, to no avail.
Regards,
Roman
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
So I just added the infamous
<meta http-equiv="X-UA-Compatible" content="IE=9" >
... and I got out of IE 7 Land. :) No HKLM key necessary here at least.
# re: Web Browser Control & Specifying the IE Version
Hello Rick,
I'm trying to use Whatsapp in my application. I'm using visual studio 2012. I couldn't find any browser (IE 11 as well) working with it. Only Edge 14.14393 (which I have in my pc, not sure about other versions of Edge.) is letting me open Whatsapp. But Edge is not running in Webbrowser control. I tried to following :
- manipulated
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> - Registry Hack, Setting 11001 in FEATURE_BROWSER_EMULATION but with no luck.
it always suggests to use modern browser.
Any help would be greatly appreciated.
Regards,
Lalit
# re: Web Browser Control & Specifying the IE Version
Hi,
is it possible to brint the IE compnents for i.e. IE 10 with the application for systems where a smaller version (i.e. IE 7) is installed and use them?
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
Issue: Some icons are not loaded properly when i load the website in Browser Control.
- I am using kendo js for a web site and it loads icons for Edit and Delete buttons for a grid
- But when i load the website in browser control, the icons are not loaded.
- I set the browser to IE11 using FEATURE_BROWSER_EMULATION. So this is running in IE11.
Some weird behavior i see is that, The icons are loadind in the following scenario:
- Open the same web site in Internet Explorer browser and then open the web site in Browser Control. The icons for Edit and Delete buttons are displayed.
- Close Internet Explorer browser and reopen the browser control then the icons are disappeared.
Thanks, Santhosh.
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
Wonderful post, it almost saved my life (at least a big part of it). Thank you very much.
Sadly, I have a little issue I can't solve: I'm trying to get information from a theater schedule where dates are in format "ddd dd/mm", in Internet Explorer 11 and Chrome, no problem. But in the webbrowser in my application, it returns "mar Nan/Nan" instead of "mar 21/03" (mar is for "martes", we are talking about a spanish web).
Did you find this kind of issue? Do you have some clue to solve it?
The next step I'll take is change the value of the combobox of dates and re-load the page. Maybe it would work.
Thank you again for sharing your knowledge.
Best regards.
Eric.
# re: Web Browser Control & Specifying the IE Version
@Daniel - IE7 is the default so if that's what you want you don't do any of this and just use the default.
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
Issue: Some icons are not loaded properly when i load the website in Browser Control.
The above issue happens only in Windows Server 2012 R2 OS and if i disable IE Enhanced Security Configuration Off, the icons are loaded properly.
Is there any way we can override or change some browser setting and get these icons displayed in browser control with turning off IE Enhanced Security Configuration?
Thanks, Santhosh
# re: Web Browser Control & Specifying the IE Version
@Santhosh - nope. IE security policy affects ALL browser instances so that has to be set first in order for anything to work.
# re: Web Browser Control & Specifying the IE Version
You friggin LEGEND! Mate, I was stuck on this problem for ages and by chance a Google search brought up this web page. Thanks so much from us downunder.
# re: Web Browser Control & Specifying the IE Version
Hey Rick, Frank from Berlin here!
Stumbling through my bookmarks I read through this post (again) and found something new!
I'm using FEATURE_BROWSER_EMULATION registry keys for years but did not know about the meta tag alternative. This is very useful for cases where I have control over the content. Especially when working within the VFP IDE. I can't use the registry settings for vfp9.exe, as I'm also using vfp's environment manager and this stops working with more current emulations (at least with the settings I tried). Using the "X-UA-Compatible" mode I now can use css3+ as well as the old evironment manager.
BTW. I found that a registry key value of 0 seems to behave like "latest installed". No indepth investigation but 0 works fine for me with wwhelp.exe, hh.exe and foxhhelp9.exe as well as my application. For Foxhhelp9.exe I also set the registry key in DOS - Format (FOXHHE~1.exe). This made it work on one machine.
Regards
Frank
# re: Web Browser Control – Specifying the IE Version
<meta http-equiv="X-UA-Compatible" content="IE=10" >
..that was enough to get all my HTML5 funcionality working - no reg tweak needed (of course IE10 is needed on the machine running the VB6 exe)
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
Hello from Canada.
WOW! Thanks for this. In one of our VFP9 products we use a third party HTML control to display maps. We have struggled with this problem for years (IE compatibility mode warnings).Your suggested solution solved all our issues. Finally! Thanks so much!
# re: Web Browser Control & Specifying the IE Version
Hi Rick, firstly thank's for your help, this aricle is very helpful and sorry for my english. I have two questions:
1.- Is it possible to run te developer toolbar from webbrowser component with F12 like Internet Explorer?
2.- What is the relation beetwen de and . I don't understand that: "Internet Explorer 11. Webpages are displayed in IE11 Standards mode, regardless of the !DOCTYPE directive."
I hope I have explained it well. Thank you
# re: Web Browser Control & Specifying the IE Version
@Pablo - 1 - no you can't run the developer tools. They are not part of the control, they are part of the IE Application shell which is not part of the Web Browser control. You can however use FireBug Lite as an addin to at least get proper Console Output.
# re: Web Browser Control – Specifying the IE Version
Thank you so much for this article!
I am however experiencing problems and was wondering if I am doing something wrong or it is caused because it is not 100% IE9. I have updated the registery in both places, and put <!DOCTYPE html> and <meta http-equiv="X-UA Compatible" content="IE=9" /> on my page. I have set registry entry value to 9000.
I am experiencing several problems, below is a short list.
I found that the tag <section> is completely ignored, if you set css setting on it, like background-color, it doesn't work.
Another problem is with javascript, the Array.prototype.map() function just gives an error.
I hope you can help me out. Thanks in advance!
Sandra
# re: Web Browser Control – Specifying the IE Version
I was agonizing over a problem and finally gave up with webbrowser, and was looking for an alternative on stackoverflow when I stumbled across a comment about "feature mode emulation", and suddenly I realized that was my problem. I was simply trying to make a webbrowser login to tumblr. I couldn't even get it to work typing it and clicking myself.
Thought the problem was something to do with: oAuth, tokens, cookies, https not working when ScriptErrorsSuppressed = True, and several other things but it never occurred to me that my VS2012 on Windows 8 was running IE in IE6 mode! Jeez!
# re: Web Browser Control & Specifying the IE Version
What tripped me up: there's a group policy setting which causes browser-emulation settings in HKCU to be ignored:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Security_HKLM_only = 1
'This is a Group Policy setting at Computer Configuration/Administrative Templates/Windows Components/Internet Explorer/"Security Zones: Use only machine settings"'
Regards,
Manuel
# re: Web Browser Control & Specifying the IE Version
Hello Rick, That was of great help! I struggled a little with how to find the name of the .exe file because I am not building an executable, just a macro-like thing for a plugin for a desktop application. So I would like to add that just using an Asterisk as the registry key name would force the usage of the specified version of IE on ALL apps that use Web browser control.
# re: Web Browser Control & Specifying the IE Version
How can a WebBrowser control be forced to open the most recent version of IE? I mean without using emulation mode and without having to change any Registry keys?
# re: Web Browser Control & Specifying the IE Version
I have a peculiar problem with BrowserControl. Rendering performance degrades over time if I run IE in parallel. If I use Fire Fox or Chrome no such issue exist under same conditions. Any idea?
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control & Specifying the IE Version
Hi There.
Does any of you have experience in doing this for app running under Windows service ? For me it does not work.
Here is how i see this: Im opening some modern page (precisely an Office365 Sharepoint page). Those pages have limitation to IE 10 or later. If you open it with older browser, there is an error (not bad rendering, the page does not open at all) So i have my App with WebBrowser control and saw this error. Then i changed registry key for both HKCU and HKLM and it did the magic ...., but only when i run my app from command line. (or from VS or whatever) But the final goal is to run app from Windows service. And when i do, i still get this error. So my conclusion is that this setting does not affect apps run from windows service. Any idea if this can be changed ?
thanks.
# re: Web Browser Control & Specifying the IE Version
@Maciek - you either need to set the key on HKLM (which is global) or for the specific user account that's going to be running the application. If you're running a service that account will be the specific user assigned to that service (SYSTEM by default).
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
Thanks the article helped a lot! -- One question, while I am trying to do the same thing on a Citrix box, the IE browser that is rendered for my application still says IE7 (default) though I change the DWORD value for my application's process.
Note: -- this works perfectly fine on the local machine.
Regards, Brij
# re: Web Browser Control & Specifying the IE Version
I am SO grateful to have found this article - the behaviour itself (much less the fix) is not detailed anywhere in the Microsoft documentation I went through, and I was about to beat my head in trying to get jQuery loading in the web app being displayed in my app's WebBrowser control.
Thanks very much indeed!!!
# re: Web Browser Control & Specifying the IE Version
Thanks for the advice on setting the IE Version. Is there anyway to get it to report this as the Browser version. We use Google Maps and it shows the map but also shows a warning that we are using an old version of the Browser.
# re: Web Browser Control & Specifying the IE Version
@JohnK - it should show the correct browser version if you use the registry hack. If you use the Edge mode header the user agent shows the original with some edge mode additions to the UA string.
# re: Web Browser Control & Specifying the IE Version
You can Inject the meta description on loading the website, previous to rendering. That what you don't need neither to modify the page (what usually is not up to you), neither to insert a registry key (that is a intrusive operation in the user machine)
# re: Web Browser Control – Specifying the IE Version
Oddly, I'm seeing behavior that nobody has described here. While the rounded corners render as they should, the buttons do not render the same as they do in the stand alone IE.
I've got a simple VFP9 app hosting the IE control and it loads up your demo page:
http://www.west-wind.com/WestwindWebToolkit/samples/ajax/Html5AndCss3/RoundedCornersAndShadows.htm
While the rounded corners work once the Reg Hack is in place, the login button does not render the same as it does in the hosted ie control. I'm on 64bit windows 7 with IE9. Does it work for you? Any suggestions what's causing this odd behavior?
Much appreciated-
Steve
# re: Web Browser Control & Specifying the IE Version
Did not work for me. I have to specify these registry for powershell.exe as my snapin works with Powershell. Do we have to do something different for Powershell snapins?
# re: Web Browser Control & Specifying the IE Version
@Vikas - Powershell.exe is probably not your host process. Powershell is console - it doesn't have direct access to the Windowing subsystem so if you have UI of some sort there must be something else running that.
# re: Web Browser Control & Specifying the IE Version
@Rick, thanks for your response. I am loading a snapin in Powershell and to use it I need to authenticate. It is this authentication dialog where the latest IE version has to be used. I open task manager and right click on "Authentication" and choose "Go to process" it always shows me powershell.exe. That is why I was creating those registries w.r.t powershell.exe
# re: Web Browser Control & Specifying the IE Version
@Vikas - Check to see whether the version is set on HKLM or HKCU already. Might be something is overriding the value you are setting.
This should work, but note that the meta Edge tag will override the underlying Reg setting, so if the page has that header in there and it's pegged to a specific IE version that might be the problem. MS internal pages often use this to ensure backwards compatibility.
# re: Web Browser Control & Specifying the IE Version
I just checked at relevant locations but I did not find any registry that was already set. Also, I don't feel that the Edge tag is overriding these registries as I know of few other applications which authenticate the exact same way. But these are independent applications and not powershell snapins.
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
I believe there is a typo in the naming of the HTTP response header. Should X_UA_Compatible: IE=edge not read X-UA-Compatible: IE=edge?
See https://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx and https://en.wikipedia.org/wiki/List_of_HTTP_header_fields.
There are two occurrences of this misnamed HTTP response header in the blog.
Best regards, Christoph
# re: Web Browser Control & Specifying the IE Version
@Christoph - thanks for catching that. Updated.
# re: Web Browser Control & Specifying the IE Version
Luis Llamas September 15, 2017
"You can Inject the meta description on loading the website, previous to rendering. That what you don't need neither to modify the page (what usually is not up to you), neither to insert a registry key (that is a intrusive operation in the user machine)"
I'd love to see a working example of this, it makes the most sense to me?
p.s. great post thanks Rick 😃
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
I have a website which uses windows authentication and when i access it in IE browser it ask for user name and password in a prompt. But if i access the same url from Microsoft Web Browser active x control it is not asking for Username and password, it shows a blank page.
I have set Prompt Username and password option in Internet Explorer → Internet Options.
Thanks, Santhosh
# re: Web Browser Control & Specifying the IE Version
@Santosh - that works for me. You may not be asked for permissions on a local domain - it may just automatically log you in.
# re: Web Browser Control & Specifying the IE Version
Greetings. I have to display in the webcontrol object of a simply vb net application, a simply html page. What i see is different from what i have designed, so i tried to use the meta tag attribute. Well, there is no effect at all; no matter what i write, the OCX always emulated IE7 !! The registry hack soles the problem, but i am here asking why the meta tag is useless i my case. Regards.
# re: Web Browser Control & Specifying the IE Version
Hi, Rick. Is this still working with these days edge versions? Will work al least for a couple of years? Thanks in advance.
# re: Web Browser Control & Specifying the IE Version
@Carlos - yes the Web Browser control still works and is still a built-in system component. I doubt it'll go away, but it won't be updated obviously. And more and more stuff doesn't work with it, but if you're rendering your own content and you stick to HTML 5.0 and ES2015 code it still works as it always has. I have several apps that use the old control that won't be updated and they all still work.
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
I have changed the registry key to use 11001 but still there are javascript errors showing in browser control. However these errors are not showing when I open in browser separately. It seems there are javascript ECMA6 compatible syntax like "let" "of" is not understandable by browser control and throws error. Does this registry change, enables browser control to use latest version of javascript ?
Thanks Mohit
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control & Specifying the IE Version
Even though I added it loads on IE 11 and not edge. How can we force control to use IE edge without using registry? Used below script to check the version. function Check_Version(){ var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet\ Explorer'){
var ua = navigator.userAgent,
re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
if (re.exec(ua) !== null){
rv = parseFloat( RegExp.$1 );
}
}
else if(navigator.appName == "Netscape"){
/// in IE 11 the navigator.appVersion says 'trident'
/// in Edge the navigator.appVersion does not say trident
if(navigator.appVersion.indexOf('Trident') === -1) rv = 12;
else rv = 11;
}
return rv;
}
# re: Web Browser Control & Specifying the IE Version
@Thushara - AFAIK there's no way to set edge mode that works for all versions. At this point you probably should just force IE 11 given that it's the browser that will be used on most machines Win7 forward (via install or Windows Update).
# re: Web Browser Control – Specifying the IE Version
...but what i have to do if my application is an asp.net page?
I'm using the webbrowser control in a server page ( Razor, but it's not the point ) to capture the screnshot of a given url and save it to disk.
What application ( .exe ? ) i have to specify in the registry key?
Could you help me?
Thank you in advance :-)
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
I can confirm that with Win7/IE11, using dword value '0' for the registry key of your app will default to the installed browser version
# re: Web Browser Control & Specifying the IE Version
11000 (0x2AF8) Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
Why IE9 mode? I think this is a typo - should be IE11. Same with the IE10 entry below it.
# re: Web Browser Control & Specifying the IE Version
This article is really great, I've lost count of how many times I've been referencing it in the last 3 years!
I have a question which I hope you can answer: what about CHM help files?
Can the browser compatibility mode be used also to affect how CHM files are viewed in Windows? ie: instead of an ".exe" file, can a ".chm" file be provided in the key?
This would be great, since I've noticed that currently CHM files offer poor html support — e.g., preformatted code blocks don't handle whitespace in a true verbatim way, and space entities need to be used; and of course, some HTML5 would make for better CHM documents.
My guess is that Windows CHM viewer also uses the WebControl for display CHM files (which are just HTML contents after all), but I'm not sure if it's handled with the same default settings as the WebControl is in user applications, or if instead MicroSoft supplies some special settings for CHM files, and whether these can be overridden by the reg key or not.
Any ideas on this? Did you have the chance to experiment it?
# re: Web Browser Control & Specifying the IE Version
@Tristano - yes you can use it on CHM, but it's a global setting. You have to set it on hh.exe recall which is the help viewer.
There's a post in that regard: https://weblog.west-wind.com/posts/2012/feb/15/make-your-chm-help-files-show-html5-and-css3-content
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control & Specifying the IE Version
Thank your prompt reply Rick — and forgive me for this late response, but my PC crashed and had to reinstall from scratch, and I've just managed to recover this link now that I'm back working on my project.
I've read the article you've linked, very interesting (and well written). This is exactly what I feared, ie: a setting that would affect all CHM files. So, I guess it would be a bad idea as this might compromise how some CHM Helps are displayed, especially those whose author has strived to beautify with custom CSS. Usually CHM authors expect hh.exe to run with default settings.
It's a pity that Microsoft didn't come up with a similar registry key for CHM files, which the help viewer could check before opening the CHM file. I mean, this issue of the WebBrowser control has a long history, so MS could have thought of this, but apparently they didn't.
From what I understood, currently MS has no plans to drop the old WebBrowser control in favour of an Edge-based modern control. I wonder why that is.
I understand that Microsoft as adopted some modern alternatives to CHM in the documentation of MS Visual Studio, that rely on a viewer that is installed with MSVS. I haven't had a chance to actually use them, but I've heard of a .hxs extension — I've tried to search into it but MS has confused even further things by using names as "Microsoft Help 2", and during development even "MS Help 3.x".
I find it really frustating that the WebBrowser control limitations have prevented the creation of some cross platform system for local HTML-based documentation. I've looked into your West Wind Html Help Builder, and I think it's fantastic that Markdown can be used to maintain documentation for both the web and CHM files.
The reasons that got me to this article are that in the past I've worked a lot with executable ebooks (or "compiled websites", as they were often referred to). They were quite trendy in the late 90's, but then faded away; one of the main reasons being lack of cross plaformness, but also the WebControl IE7 limitation. Unfortunately, none of these eBook compilers have been updated to add the registry hack to emulate IE11. Some eBook compilers offer some custom scripting extensions allowing to tweak the registry, this allows creating workarounds to fix the web browser compatibilty issue (I've managed to achieve it with 2 eBook compilers, but none of the solutions was too elegant in the end).
For a long time I've been tinkering with the idea of creating an eBook compiler that would produce cross-platform HTML documentation in a self-contained binary. But it seems that Windows WebControl (with all its emulation limitations) makes the task easier through Windows URL monikers, custom protocols, WinAPI events handling, etc., and that achieving the same on Linux and macOS wouldn't be quite as simple.
When Chromium came out I though it would finally be possible, but then I saw that you can't create a standalone binary using CEF — lots of dynamic libraries, and quite heavy too.
If West Wind Html Help Builder could create cross platform binary standalone documentation files, whose contents can't be hacked, it would be really superb. Currently documentation is always a problem in cross platform applications, as there is no equivalent of Windows CHM Help system on other OSs (especially when it comes to jumping to a specific Help entry). This is a huge gap that has yet to be filled — and probably because no one has pushed hard enough to do it.
Executable eBooks are the closest solution I've seen so far to replacing CHM help iles, except that all such compilers relied heavily on MS WebControl and no one looked on how to implement the same on Linux and Mac. It's quite likely that a truely cross platform solution would require creating a custom cross platform browser control — for documentation purposes, it wouldn't have to implement fully HTML5/CSS3, just typography and images.
I guess you must have given your own thoughts on this very issue, having developed West Wind Html Help Builder and Markdown Monster, and realizing how important documentation is, and that most of today eBook like standards are not really concerned with protecting the contents.
# re: Web Browser Control – Specifying the IE Version
I'm trying to have a single winforms application with a tab control that displays a different IE version in each tab. Yep at the same time.
If I could "fake" the application name depending on what tab I was on that would do the trick.
When IE control goes to load a page, I'm sure it checks the registry with the name of the exe that it finds itself in, correct? So I want to hack / fool that API call.
# re: Web Browser Control – Specifying the IE Version
yes, this is possible, by hosting multiple exe's in the main exe.
http://www.codeproject.com/Articles/9123/Hosting-EXE-Applications-in-a-WinForm-project
# re: Web Browser Control & Specifying the IE Version
Hello, I don't want to add the registry setting for IE version, Instead of i am using the Meta tag for IE version
Still I am not getting proper UI.
If I use the registry setting,getting proper UI. Any help or suggesting?
# re: Web Browser Control – Specifying the IE Version
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.
Furthermore, you can do this at runtime by writing to HKCU\Software\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION, so long as you write your executable name in before instantiating any web browser controls. When writing to HKCU, you (a) don't need elevated privileges, and (b) don't have to worry about 32 vs 64 bit -- the wow6432node key is not used in HKCU.
# re: Web Browser Control & Specifying the IE Version
On your link to the MSDN page on the registry settings "(taken from MSDN here)", the shortcut is wrong. It should be "browser-emulation", not "browser_emulation".
It would appear that this shortcut changed when the MSDN article was moved from the referenced location to an archived ("previous-versions") location.
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control & Specifying the IE Version
I'll echo the many other comments - fantastic article. My language is Delphi 2007, and the Registry Hack was exactly what I needed. Works fantastic in HKCU. Like you, I use inno setup, so your example saved me a little time there. Perhaps most importantly, you deserve recognition, not only for a great article, but for how well you support and respond to all the comments that have been made over the years. Hats off to you.
# re: Web Browser Control – Specifying the IE Version
Thanks, thanks, thanks....
I was frustrated trying WebBrowser control work in a multiple year development product.
You saved me many months for change the control with another one, and tons of work.
Thanks so much,
Carlos
# re: Web Browser Control & Specifying the IE Version
Hi Rick First of all can I add my thanks for this webpage- now 7 years old but still the best reference for this issue
Unfortunately it hasn't solved my specific problem - perhaps you can advise:
I have been successfully using code in Access for users to get their current geolocation. It works as follows: The code loads an HTML map in IE which asks for permission to get the current location. If this is granted, data from the geo-sensor built into many PCs is obtained (where available) & the co-ordinates are displayed in the HTML file and the location is marked on the map. The data is then read by Access & used to download a Google static map centred on that location (after which other tasks are done). All worked fine until the latest Windows update to version 1803. Since then IE reports that 'the geolocation service failed' If I load the same file into Edge, the correct location is still obtained. However, Access code requiring data from a web page ALWAYS uses IE no matter what the default browser is.
I've done further tests on this issue using the following devices
- Win 10 tablet running version 1709, IE11 & Access 2010
- Virtual machine running Win 7, IE11 & Access 2010
- Virtual machine running Win 7, IE11 & Access 2007
All were successful However another test using Win 10 version 1803, IE11 & Access 2016 failed
The same issue can be seen by loading the w3schools geolocation feature (which uses similar code to mine) in different browsers. See W3SchoolsGeolocation web page: https://www.w3schools.com/html/html5_geolocation.asp Using Edge it works correctly Using IE since the update, clicking the TryIt button does absolutely nothing - no error but nothing happens
I'm unclear whether this is a bug or if the IE geolocation service been deliberately disabled e.g. to manage a security issue? If its a bug, what's the best way to report it to MS?
# re: Web Browser Control – Specifying the IE Version
Really appreciate all the tips and info over the years. This tip in particular has helped me with an issue that's plagued me for the last several years.
My application of the webbrowser control is not nearly as sophisticated as many of the posters here, but once I edited the registry, I was able to get correct rendering and other behavior in IE 11.
I do still have a problem, though.
The InnerText property of the document now contains (or at least now returns) HTML along with the text, where previously I was able to capture only the text.
Do you know of a simple way to extract only the text (i.e. remove any superfluous HTML?
Thanks for any help.
Joe
# re: Web Browser Control – Specifying the IE Version
# re: Web Browser Control – Specifying the IE Version
Operator error, as usual. :-)
Thanks!
Joe
# re: Web Browser Control & Specifying the IE Version
I was looking into this issue and I found that there is a new browser control using edge https://blogs.windows.com/msedgedev/2018/05/09/modern-webview-winforms-wpf-apps/ webviewcontrol https://docs.microsoft.com/en-us/uwp/api/windows.web.ui.interop.webviewcontrol webview https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview
# re: Web Browser Control & Specifying the IE Version
Hi Rick,
I have integrated webbrowser control in outlook - custom task pane where html form gets display. I have browser emulation registry entry with outlook.exe and value 11001. I think it works fine as html form loads and as such no error also user agent shows proper IE11.
One issue I see is "onkeyup" javascript event is not working there. however, if I try same form in any winform application or in IE it works fine. Not sure any issue with outlook.
There is one more focus specific issue as well https://social.msdn.microsoft.com/Forums/en-US/0e411bc7-1dba-4a22-86a6-20529e4fe8ea/focus-problems-with-task-pane-and-webcontrol-in-outlook?forum=outlookdev&prof=required
Do you have any idea about these issues ?
Thanks, Manoj
# re: Web Browser Control & Specifying the IE Version
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
... other headers
</head>
<body>
... content
</body>
</html>
This really Worked thanks
# re: Web Browser Control & Specifying the IE Version
I am using Web browser control hosted by a SCADA Software. The web page is not being displayed properly. It gives some script error. However the same web page is properly displayed when i try to open from a stand alone Microsoft IE 11. I tried adding the key in the registry setting with a value 11000 for IE 11. However it did not help. After the registry setting, when i try to run that software that hosts the web browser control, it shuts down immediately. Any help is much appreciated in this case.
Thanks, Manimaran
# re: Web Browser Control – Specifying the IE Version
I was doing some tests with d3.js in web browser control inside a vfp form, and was getting script errors.
Many many thanks to Rick as well, you're a real gem!
# re: Web Browser Control – Specifying the IE Version
Rick:
Thanks to you, I got it to work on Win 8 with IE10. ( No luck on Win 7 with IE9.)
But.. (always a but).. I have a Windows Form application using a webbrowser control to automate navigation through a web site. At one point, I must click on calendar control that causes navigation to another page. In a free standing browser (IE9 or IE10) clicking a day on the calendar causes immediate navigation to the desired page with virtually no delay, but in the webbrowser control, clicking a day causes a call to the server and postback with substantial delay before switching pages. The html for the calendar days uses j-stuff that I really don't understand, and don't know how to trigger.
Any ideas would be greatly appreciated.
Paco
# re: Web Browser Control – Specifying the IE Version
The short version of my previous comment is this..
Even with IE 10 in my webbrowser control, handling of jscripts or jquerys is different than in a free standing browser.
Can you shed any light on this?
Paco
# re: Web Browser Control – Specifying the IE Version
After spending a couple weeks working on the web pages in an embedded device, I was pretty happy with the results -- I had even added some extra code to get things to work as far back as IE8 (which is as far back as we're willing to support). Then I fired up a windows app that ships with the device and contains an embedded IE control. Of course, it looked like a disaster. For a while, I thought I was going to have to start all over again. Then Google let me to your blog, and my problem vanished.
Many thanks...