Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

Web Browser Control & Specifying the IE Version


:P
On this page:

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-Compatible Meta header
  • Using Application specific FEATURE_BROWSER_EMULATION Registry 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:

Full Web Browser Rendering  

Web Browser Control in a WPF form:

WebBrowserControlWpfForm

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:

Registry Settings in HKCU

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.

Posted in Internet Explorer  .NET  FoxPro  Windows  

The Voices of Reason


 

Vish
May 24, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Nice! Very useful and timely for me :) One question I had that I thought you might be able to help with was whether application configuration is done only name. So, if there are multiple apps with the same name on the machine, all of em are forced to use the same IE settings?

Thank You,
Vish

Rick Strahl
May 24, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Vish - yes it looks like the feature emulation is tied to the EXE name so if you have multiple copies they all use the same settings. But that begs the question. Why on earth would you want to have multiple settings for the same application (other than possibly a runtime/development environment of some sort)?

Mark
June 19, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Rick,

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

Rick Strahl
June 20, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Mark - I think it's for backwards compatibility. IE 9 actually has many MSHTML object model changes that would likely break old applications. One I've run into is that the Range objects in IE 9 use the standards based Range object as opposed to text/control ranges in the past. I recently switched an app over to IE9 operation and that broke a ton of functionality which I had to work around with client side script code called from the host application. It took a lot of experimenting to get this right because it now has to work with both old and new versions of IE (testing is a lot of fun for this).

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.

G. Andrew Duthie
June 23, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Awesome, Rick! This was just what I needed. Putting together something for a demo, and your post just saved me a ton of work.

Thanks!

Andrew

Richard
September 14, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

It's a shame they can't use the X-UA-Compatible header/meta-tag to determine the rendering engine. If the page specifies "IE=9", it's a safe bet it's designed to work for IE9, so using the IE9 rendering mode won't break it.

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.

Role
September 15, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

I also ran into the CreateRange problem and could solve it by adding my process to FEATURE_USE_LEGACY_JSCRIPT. The problem is actually caused by the new Chakra JavaScript engine, and adding your process to FEATURE_USE_LEGACY_JSCRIPT causes the WebBrowser control to use the legacy JavaScript engine, which doesn't have the problems with CreateRange.

Rick Strahl
September 16, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Richard - the problem is that IE needs to set up *before* it renders or even loads a page. Anything in the HTML document is too late to switch engines. Plus, once an IE engine is loaded it can't be changed for another page AFAIK. Then there's the issue of what's actually installed on the the machine. Obviously you can't render IE 9 style if IE 9 isn't installed ;-)

Rick Strahl
September 16, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Role - Ah! That's good to know. Incidentally I've had a heck of a time trying to automate the new Range API even knowing that it's different. It breaks inconsistently and causes all sorts of headaches. Will give the old API a shot and see if that helps.

Richard
September 19, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Rick - The IE9 shell manages to seamlessly switch between rendering modes based on the header or meta-tag without any problems. You can even use the developer tools to switch the browser and document modes on the fly.

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. :)

Rick Strahl
September 19, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Richard - you get no argument from me that this should be easier and most importantly more transparent. But it is what it is - AFAIK this is the only way to get later than IE 7 behavior in the Web Browser control and while it's an ugly, ugly hack to have to resort to the registry its something that can be easily enough handled by an installer.

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).

Bernard Bout
October 21, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick

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

Anil
October 22, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick,
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 ?

Rick Strahl
October 22, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Anil - do you have events hooked up to the control? There's some overhead in the ActiveX container as it has to fire events into the container - if FoxPro code runs in response to anything in the DOM it'll likely slow the browser down quite a bit.

Rick Strahl
October 22, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Bernard - not sure what you mean. Why would there be errors in IE9 or IE7? It sounds like IE is actually rendering in the right version, but the pages you're accessing are maybe generating errors? There are IE API changes in IE 9 that can break JavaScript code that worked in previous versions.

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

Anil
October 23, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@Bernard you need to use 9999 to key to force ie9 version.
and rick i m not doing anything inside vfp just opening fishtank sample of ie9.

LambertWM
November 13, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Just wanted to say THANK YOU for posting this. I also appreciate your remark about not forgetting the to add a key for "yourapp.vshost.exe" :-)

thanks, Lambert

SebH
December 29, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks for this usefull post.
But what about if using a dll instead of a .exe ?
What value should have then key ? example.dll ? example ? c:\mypath\example.dll ?

Rick Strahl
December 29, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

@SebH - you can't do it by DLL, you can only register applications by the EXE. If it's in a DLL you need to specify the hosting EXE whatever that might be.

SebH
December 30, 2011

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks for your quick reply Rick.
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 ;)

AshB
January 10, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Thank you, thank you, thank you!

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

Phillip
February 02, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

I found this:
<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?

markh
February 12, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

OMG!!! Rick, you're right, this IS HUGE! I can't tell you how many hours and days i have researched and tried all sorts of things to get the webbrowser ctrl out of ie7 mode. Serveral posts I've seen hinted to it, but I couldn't find the answer anywhere. You totally blew me away when i found this post. I use the webbrowser for Editing and display extensively in my app for users to create markup which gets inserted in emails or web page content. The ie7 code with all caps tags, invalidated xhtml. And though it doesn't create self closing tags like you mentioned such as <br /> a lot of that can be cleaned up with STRTRAN() in vfp. Again, Thanks a ton Rick for posting this, and writing it so clearly too! Your posts are golden.

And Role, thanks so much for your post on the FEATURE_USE_LEGACY_JSCRIPT. That solved the createRange() issue.

markh
February 14, 2012

# Using DesignMode="On" with ie9

For me, I use Document.DesignMode="On" instead of Body.contentEditable=.t. The main reason is that if you have <input> elements that you want the user to be able to specify the default values for (by typing directly into the input's textbox), contentEditable will not update the "value" attribute of the element. For example:

<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.

markh
February 14, 2012

# DOCTYPE of HTML 4.01 or higher issues with WB ctrl

When I use the WebBrowser control to edit a document that has Doctype set to:
<!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.

Bryan
February 15, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

This site appears to be only place on the web that contains this information. Because of you, I was able to solve a client problem within 15 minutes and the customer was happy.

Rick - you da man! Thank you for posting this!

David
February 19, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Rick,
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.

Rick Strahl
February 19, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@David - I suspect you're not actually running a 64 bit version of Windows. The wow6432Node key is where the registry is redirected to by 32 bit applications so it has to be there on a 64 bit machine that has any 32 bit apps running (and it will - even Windows natively has many 32 bit apps).

I tried the meta header, but that only affects the rendering style once the browser is loaded. For me that alone didn't work.

Ken
March 21, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Rick, Thanks - it works as you said. Question is it possible to force a 64 bit wpf app to only use the 32 bit browser with a similar reg edit? My issue is pdf's - they open correctly in a 32 bit wpf app but when running 64 they need to open a new IE browser. Thanks again

Asdf
April 20, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

>> what happens when setting 9000 with IE 8 installed?
>> 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.

kobik
May 16, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@Rick, very good post! Thanks.

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?

Rick Strahl
May 16, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@kobik - I haven't figured out a way to do this at runtime. I suppose it is possible since the IE Tools let you switch the engine on the fly but I have no idea how that can be done. As far as I can tell the values are read only when the engine is created in an app for the first time.

lampson
June 10, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Hi ricky,

that is just what I want. It works and save a lot of time for me.

Thx a lot.

Jeff Rhodes
July 27, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Just wanted to say how useful this page was for me. I was tripped up by the fact that the key did not seem to be working because I was running in Visual Studio. Your <appName>.vshost.exe advice worked perfectly. Your site has been helpful to me multiple times. Keep up the good work!

E.R. Gilmore
August 21, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

I have some jQuery in a page that I'm trying to hit from an activex browser control. It works fine in a regular browser but not the activex. The problem is that the activex is not in my application, so I can't change the Registry values.

Rick Strahl
August 21, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@ER - you should set those registry values when the app is installed using an installer. That's the only way I've found that to work.

Jim Tollan
September 04, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Hi rick,

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

Rick Strahl
September 04, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@Markh - to remove the scroll bar you can set: html,body { overflow:none }. You can also explicitly reference the document and set the scroll style to none from code.

zxMarce
September 13, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Rick,

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.

shane
October 02, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks god it works like a champ. I've been searching for this for years and finally found it here. God bless you, Rick, God bless you !

JD
November 10, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks man! I've been searching for this for months!! FINALLY found it here. Been working on a project to parse email from Yahoo... but the Yahoo Email App would never display properly so I couldn't emulate clicks properly. Very helpful with automation!!!

John Kortis
November 22, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks for this, it has been a wonderful help. Quetsion though, Crystal Reports renders larger in the COntrol than in the browser, even with the settings.... any thoughts

simon
December 10, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

again MS stuff up with this pathetic override. What sense does it make to add the "application name" for the exe, when there could be multiple different applications with the same EXE name. there is no global identifier for apps to prevent users installing same named exe's, but MS couldn't think logically yet again. Why not just put the EXE's full path in the registry? I don't know, maybe that makes too much sense? This override has the potential to really stuff up other vendors apps when setting for your own exe.

Rick Strahl
December 11, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@Simon - I guess this means you should make sure your application uses a good solid unique name :-) There are serious issues with this whole affair for sure, but naming conflicts are probably the least of the problems you have to worry about.

Rich
December 14, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks for this, very helpful! Just one question: is the 7000 (IE7) mode the same as the default webbrowser control setting (= no registry entry)? If not, what's the difference?

Thanks!

Rick Strahl
December 14, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@Rich - yes it would appear that's the default setting.

Icey
December 20, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Hello! But in my application, it seems not work at all.

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
        }
        
    }
}

Rick Strahl
December 20, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@Icey - this is a terrible idea. For one thing most applications won't have rights to write the registry key and that's most likely what's happening.

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).

Icey
December 20, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks.

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.

Rick Strahl
December 21, 2012

# re: Web Browser Control &ndash; Specifying the IE Version

@Icey - All I can tell you is that this works for every application I've tried. Just make sure you write the right keys and in the right place in the registry for 64 bit and 32 bit applications. On 64 bit systems you have to write it into both places as 32 bit applications will look in one place and the 64 bit ones in the other.

Vibhore Tanwer
January 06, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hi, These settings are not working on Windows 8 64 bit version but works fine on Windows 8 32 bit version. Any help why that could be happening?

Rick Strahl
January 06, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Are you setting both the 32 bit and 64 bit keys? You need to set both since on a 64 bit machine both are used. 32 bit apps use the 32 bit version of the Web Browser control, 64 bit apps use the 64 bit one.

Vibhore Tanwer
January 18, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Yes, I am setting both the keys, my application is 32 bit WPF application and these settings works well on 32 bit version of Windows but not on 64 bit version of Windows. It fails on both Windows 7 64-bit and Windows 8 64-bit. Is there anything else that I am missing?

paul
January 22, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hey thanks... was looking everywhere for exactly this but happened to stumble on it almost by chance (or is it simply that we are generally not enough aware of all that is going on) :)

Dmitri
February 14, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

as pointed out above, can't get it to work on Win 8 64 bit. same wpf app works on Win7 64 bit. both 32 and 64 bits keys are set. Has anyone been able to get it to work on Win8?

Rick Strahl
February 15, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

@Dmitry - hmm... works for me. Both 32 bit and 64 bit compiled versions of my EXE work and show rounded borders and shadows.

Make sure you're explicitly running the EXE and not out of the Visual Studio debugger because the debugger actually uses a different hosting EXE! Also make sure the name matches exactly in the registry and you're using the right kind of value (DWORD).

Note too that on Windows 8 you can use 10000 for IE 10.

Dmitri
February 15, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks Rick! I tried different combinations of x86 and 64 bit still no luck. I made sure to run the right exe. I actually develop on a win7 comp and then copy to a win8 machine. strange.

Dave
March 15, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hi, I am having the same problem with Win8 64bit and VS2012. This solution is not working. Browser keeps saying IE7. Very frustrating. The application is specifically for a kiosk, so I suppose I could always install 32bit. Anyone manage to figure this out?

Paco
April 05, 2013

# re: Web Browser Control &ndash; 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

Paco
April 06, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Rick:

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

Tom Py
April 19, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks SO much. I just started getting script errors this year in an app I wrote years ago that actually stopped loading data from site when it got the error. With this fix, which I did not see anywhere else through Google, my app loads the flash data properly.
I'm using ie10 in windows 7 and 270f hex worked for me.
Thanks!

Rainer Euhus
May 17, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick,

Thank you for the information.

Solved a problem with a 'position: fixed' element, which wasn't displayed before I added the registry entry.

Jon Alonso
June 17, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Thank you for the article! I found it more than useful. I was struggling with the CSS differences between my IE8 and the embedded browser, but changing the latter to IE8 mode just solved the problem.

Drew White
July 27, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

The answer was in here - but for me proved simpler than any of the full resolutions suggested. Since I personally only needed to display HTML that I was generating in that window, I found that by adding:

<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)

Plasbot
August 28, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

A thousand thanks to you friend!
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!

Per
September 02, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick, I really have a strange issue here and hope you can help.

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??

Per
September 02, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hi again Rick.

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.

Sandra
September 12, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick,

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

Carlos Cuesta
October 25, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick,

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

markh
November 26, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

Just FYI, in case anyone's having issues with IE11 and the webbrowser control...

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!

Rick Strahl
November 26, 2013

# re: Web Browser Control &ndash; Specifying the IE Version

@Markh - the createRange() problem has been a problem for a while dating back to IE 9 and standards mode. Starting with IE 9 IE is using use DOM compliant range functions rather than the old IE based ones (which were far easier to use). Basically you have to decide which version to use and make sure that you use the right functions for that version. The 8888 forces IE 8 mode explicitly so you're staying on your compatibility mode, but won't get the newer rendering features of IE 11.

sellenoff
March 18, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Great post Rick. Been searching for awhile to solve this!

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

Denny
May 08, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick, great post...
...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 :-)

Rick Strahl
May 08, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

@Denny - wow really? :-) I hope that's an internal thing you're doing... Anyway the process would be Internet Explorer or iExplore.exe I think.

Steve
May 10, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Very nice. Thanks. Any thoughts on updating keys when a ClickOnce app is used?

Olivier
May 21, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Thank you for this very useful informations.

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

iceuponfier
June 06, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks you very much everyone for the infos about the dword value "0", it's help a lot!!!! By the way the microsoft documentation explain you can also push this configuration into the HKEY_CURRENT_USER key :)

Todd Morrow
June 24, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick,

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.

Todd Morrow
June 24, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

ok let me answer my own question...

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

Marc
July 15, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Two of the values for IE10 and IE11 are incorrect in your table (you had 11999, 11000, 10999 and 10000). According to the MS documentation you link to:

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.

Joe De Ville
September 26, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Rick,

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

Rick Strahl
September 26, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

@Joe - .innerText should always return text not HTML. If it's returning HTML you like had encoded HTML text in the element in the first place. Maybe the assignment was incorrect (ie. assigning HTML to .innerText).

Joe De Ville
September 26, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

Ahh! I see what I did now. It's javascript embedded in the content I used as a template.

Operator error, as usual. :-)

Thanks!

Joe

Theodoros Flabouras
December 20, 2014

# re: Web Browser Control &ndash; Specifying the IE Version

@Bernard: Thanks for this :<meta http-equiv="X-UA-Compatible" content="IE=9" > suggestion!

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!

Grant Edwards
February 03, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Brilliant!

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...

Hilaly Hassan
February 14, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

i tried to use embed web browser control to execute an css web menu under win xp + IE8 but in vain even though i modified the registry key as shown

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

Govindarajan
March 11, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Guys,
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

Ken
May 21, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Hi

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

RM
July 13, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Hi Rick,

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.

Ken
July 28, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Hi

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

Web Browser Control – Specifying the IE Version
August 09, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Hi,

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.

Rick Strahl
August 10, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Did you restart? The change has to be made before the app is started or else the registry change is not read.

Robert Muehsig
September 15, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

On Windows 10 it seems easier to skew things up. If you choose a "unkown" IE Version (e.g. 0) or anything else you will just see a blank page and an endless process will run.

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/

Nathan
October 11, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Awesome fix to adjust rendering for Webbrowser WPF Control. This helped me be able to display graphing in the WPF control using the Javascript package Flot.

Akabrando
October 13, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Thank you so much.
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

Matt
November 17, 2015

# re: Web Browser Control &ndash; Specifying the IE Version

Anyone have luck implementing this registry update for running the Web Browser dev tool within Powerpoint? I'm not entirely sure what application I should be writing this hack to... Any help would be greatly appreciated!

Pavel
February 05, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

Hello again,
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.

Rick Strahl
February 05, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

@Matt - POWERPNT.EXE

@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.

Pavel
February 07, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

@Rick, I'd like to avoid using files. But your suggestion pointed me to the "navigate to correct document" solution.

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

Rick Strahl
February 08, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

@Pavel - Navigating to file is the best thing you can do actually because there's an actual document there to start with. As you found out about:blank isn't a real HTML document so you can't really modify it. And you do want to navigate so you can load a complete HTML document including doc type and docheader so you have full control over the HTML rendered. That's what I do in my offline apps that use Web Browser. Additionally this is nice because you have a debug trail - you can open the doc in a different browser and use debug tools if you need to (which you can't do in the Web browser control).

Leandro Duarte
February 14, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

Thank you so mutch

Tristano Ajmone
April 12, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

GREAT ARTICLE! It was very useful...

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...

Ryanba29
April 18, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

In c# at least you can specify System.AppDomain.CurrentDomain.FriendlyName.ToString() in place of the executable name. That way you don't have to change your executable name for debug mode.

James
May 05, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

Thank you for this informative explanation.

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.

Rick Strahl
May 05, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

1.) I think VS 2015 uses a later version - they are using this registry hack as well - DevEnv is one that is listed.
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.

Paul Murray
June 12, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

Thanks Rick!!

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

Roman
June 29, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

Hello Rick,

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

Imperyal
August 04, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

This article was a life saver to me. I was getting a page for upgrade my browser (gmail OAuth2) using Asbjorn Heid's IndySASLOAuth2 authenticator for Indy (Delphi). Because Google doesn't accept IE7 for the authorization page anymore. The registry hack worked wonderfully. I'm adding the required keys/values using tRegistry on Delphi. Thank you very much!!!

Jonas
August 23, 2016

# re: Web Browser Control &ndash; Specifying the IE Version

We're using this old hulking C++ MFC application and, you guessed it, the ActiveX WebControl stuck in IE 7 Land. We absolutely do not want to rely on HKLM keys though for server installation reasons where we'd then have to involve IT departments, explain ourselves as they look at us sternly, etc.

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.

prathap
September 10, 2016

# re: Web Browser Control & Specifying the IE Version

You Saved my ass

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
... other headers
</head>
<body>
... content
</body>
</html>

This really Worked thanks

Gilbert James
September 12, 2016

# re: Web Browser Control & Specifying the IE Version

when HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION has a keyname applicationname.exe, and this is set to a decimal value of 0, what does this mean?

Harshith
January 23, 2017

# 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??


Rick Strahl
January 23, 2017

# 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.


Harshith
January 25, 2017

# 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

  1. Registry hacks using FEATURE_BROWSER_EMULATION which did not work for me.

  2. 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.


Harshith
January 25, 2017

# 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.


Rick Strahl
January 31, 2017

# 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.


Harshith
February 28, 2017

# 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.


Mark
February 28, 2017

# 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?


Rick Strahl
February 28, 2017

# 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.


Roger
March 01, 2017

# 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


Rick Strahl
March 01, 2017

# 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 ---


Lalit
March 16, 2017

# 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 :

  1. manipulated <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  2. 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


Daniel
March 21, 2017

# 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?


Santhosh
March 21, 2017

# 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.

  1. I am using kendo js for a web site and it loads icons for Edit and Delete buttons for a grid
  2. But when i load the website in browser control, the icons are not loaded.
  3. 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:

  1. 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.
  2. Close Internet Explorer browser and reopen the browser control then the icons are disappeared.

Thanks, Santhosh.


Eric MYG
March 21, 2017

# 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.


Rick Strahl
March 21, 2017

# 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.


Santhosh
March 23, 2017

# 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


Rick Strahl
March 24, 2017

# 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.


Dave H (Sydney, Australia)
April 04, 2017

# 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.


Pablo
April 26, 2017

# 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


Rick Strahl
April 26, 2017

# 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.


Mohammed
May 15, 2017

# 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.


Michael Haephrati
June 13, 2017

# 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?


lenny
June 21, 2017

# 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?


Maciek
July 28, 2017

# 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.


Rick Strahl
August 02, 2017

# 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).


Brij
August 10, 2017

# 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


Tyler Style
August 30, 2017

# 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!!!


John K
September 06, 2017

# 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.


Rick Strahl
September 06, 2017

# 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.


Luis Llamas
September 15, 2017

# 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)


Vikas
September 29, 2017

# 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?


Rick Strahl
September 29, 2017

# 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.


Vikas
October 03, 2017

# 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


Rick Strahl
October 03, 2017

# 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.


Vikas
October 03, 2017

# 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.


Christoph Kreß
October 04, 2017

# 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


Rick Strahl
October 04, 2017

# re: Web Browser Control & Specifying the IE Version

@Christoph - thanks for catching that. Updated.


Alan Gresham
October 08, 2017

# 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 😃


Santhosh
October 11, 2017

# 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


Rick Strahl
October 11, 2017

# 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.


Massimo
October 26, 2017

# 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.


Mohit Gupta
November 02, 2017

# 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


Thushara
November 26, 2017

# 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;          
	}

Rick Strahl
November 27, 2017

# 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).


EZ
January 19, 2018

# 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.


Tristano
January 29, 2018

# 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?


Rick Strahl
January 29, 2018

# 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


Tristano
February 19, 2018

# 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.


Anand Bidua
March 06, 2018

# 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?


MarkL
March 28, 2018

# 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.


Homer
April 29, 2018

# 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.


Colin Riddington
May 16, 2018

# 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

  1. Win 10 tablet running version 1709, IE11 & Access 2010
  2. Virtual machine running Win 7, IE11 & Access 2010
  3. 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?


Aaron Fischer
June 04, 2018

# re: Web Browser Control & Specifying the IE Version


Manoj
June 07, 2018

# 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


Mani
July 24, 2018

# 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


Bill Gunn
March 27, 2019

# 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 😃


Andrew
April 24, 2019

# 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?


Rick Strahl
February 26, 2020

# 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.


Haydn
March 04, 2020

# 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!


Frank
September 06, 2020

# 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


Paul
November 12, 2020

# 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!


Manuel
March 12, 2021

# 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"'

Source: https://stackoverflow.com/questions/22321424/webbrowser-control-ignores-hkcu-registry-settings-values/22334392#22334392

Regards,
Manuel


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024