Thursday, July 10, 2014

The WebBrowser in VS making you crazy with its IE7 emulation mode? Here's how you can IE 8/9/10/11 it and more... (Think "WebBrowser Control Emulation Mode" post of the day)

Robert MacLean - Improve the embedded browser in Visual Studio

Visual Studio has an embedded browser, but it uses the IE 7 render path?! Really, that is pretty messed up.

image

Thankfully, you can fix this yourself with a quick registry addition. Note: Fiddling with the registry can break your device, so be careful and this carries the usual “this works on my machine” and it is your own risk for doing this. The key you need to care about is:

... [Click through to see the reg hack... I didn't want to steal his secret sauce... ;]

I set the value to (HEX) 2af9 – since I have IE 11 on my Windows 8.1 machine, but you can pick from the list of options to best suit your needs and now it just works! No issues on GitHub

image

..."

Internet Explorer Dev Center - Internet Feature Controls (B..C)

...

Browser Emulation

Windows Internet Explorer 8 and later. The FEATURE_BROWSER_EMULATION feature defines the default emulation mode for Internet Explorer and supports the following values.

image

...

I know you're thinking, "VS just embed's the WebBrowser control, which I like to do to, sometimes. Can I make this magic happen for me too?" Or "I'd like a little more detail and depth!"

Funny you should ask that...

Cyotek Blog - Configuring the emulation mode of an Internet Explorer WebBrowser control

Occasionally I need to embed HTML in my applications. If it is just to display some simple layout with basic interactions, I might use a component such as HtmlRenderer. In most cases however, I need a more complex layout, JavaScript or I might want to display real pages from the internet - in which case I'm lumbered with the WebBrowser control.

I'm aware other embeddable browsers exist, but the idea of shipping additional multi-MB dependencies doesn't make sense unless an application makes heavy use of HTML interfaces

The WebBrowser control annoys me in myriad ways, but it does get the job done. One of the things that occasionally frustrates me is that by default it is essentially an embedded version of Internet Explorer 7 - or enabling Compatibility Mode in a modern IE session. Not so good as more and more sites use HTML5 and other goodies.

Rather fortunately however, Microsoft provide the ability to configure the emulation mode your application will use. It's not as simple as setting some properties on a control as it involves setting some registry values and other caveats, but it is still a reasonable process.

...

image

There you go! Just about everything you've every wanted to know about this (or not)

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...