Has all my video tutorials usually with source code in an organized cyber-library. This video we are introduced to the WebB.

  • Discover historical prices for C stock on Yahoo Finance. View daily, weekly or monthly format back to when Citigroup, Inc. Stock was issued.
  • Experimental C# Windows Forms WebBrowser based on Edge - hughbe/EdgeWebBrowser.
  • Do you need to embed a web browser into your.NET application, but the default MS IE-based WebBrowser component does not satisfy your requirements?

Configuring the emulation mode of an Internet Explorer WebBrowser control

Occasionally I need to embed HTML in my applications. If it isjust to display some simple layout with basic interactions, Imight use a component such as HtmlRenderer. In most caseshowever, I need a more complex layout, JavaScript or I mightwant to display real pages from the internet - in which case I'mlumbered with the WebBrowser control.

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

The WebBrowser control annoys me in myriad ways, but it doesget the job done. One of the things that occasionally frustratesme is that by default it is essentially an embedded version ofInternet Explorer 7 - or enabling Compatibility Mode in a modernIE session. Not so good as more and more sites use HTML5 andother goodies.

Apple app store download zoom. Rather fortunately however, Microsoft provide the ability toconfigure the emulation mode your application will use. It's notas simple as setting some properties on a control as it involvessetting some registry values and other caveats, but it is stilla reasonable process.

The table below (source) lists the currently supportedemulation versions at the time of writing. As you can see, it'spossible to emulate all 'recent' versions of Internet Explorerin one of two ways - either by forcing a standards mode, orallowing !DOCTYPE directives to control the mode. Theexception to this dual behaviour is version 7 which is as is.

According to the documentation the IE8 (8000) and IE9 (9000) modes will switch to IE10 (10000) mode if installed. The documentation doesn't mention if this is still the case regarding IE11 so I'm not sure on the behaviour in that regard.

ValueDescription
11001Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the !DOCTYPE directive.
11000IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.
10001Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
10000Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
9999Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
9000Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.
8888Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
8000Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8
7000Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.

Setting the browser emulation version

Setting the emulation version is very straightforward - add avalue to the registry in the below key containing the name ofyour executable file and a value from the table above.

Note: If you do this from an application you're debuggingusing Visual Studio and the Visual Studio Hosting Processoption is enabled you'll find the executable name may not bewhat you expect. When enabled, a stub process with a slightlymodified name is used instead. For example, if yourapplication is named calc.exe, you'll need to add the valuecalc.vshost.exe in order to set the emulated version for thecorrect process.

As it makes more sense to detect the version of IE installed onthe user's computer and set the emulation version to match,first we need a way of detecting the IE version.

There are various ways of getting the installed IE version, butthe sensible method is reading the value from the registry aseverything else we are doing in this article involves theregistry in some fashion.

Older versions of IE used the Version value, while newerversions use svcVersion. In either case, this value containsthe version string.

We can use the following version to pull out the major digit.

Points to note

  • I'm returning an int with the major version component rathera Version class. In this example, I don't need a fullversion to start with and it avoids crashes if the versionstring is invalid
  • For the same reason, I'm explicitly catching (and ignoring)SecurityException and UnauthorizedAccessExceptionexceptions which will be thrown if the user doesn't havepermission to access those keys. Again, I don't really wantthe function crashing for those reasons.

You can always remove the try block to have all exceptionsthrown instead of the access exceptions being ignored.

The functions to get and set the emulation version are usingHKEY_CURRENT_USER to make them per user rather than for theentire machine.

First we'll create an enumeration to handle the differentversions described above so that we don't have to deal withmagic numbers.

Next, a function to detect the current emulation version in useby our application, and another to quickly tell if an emulationversion has previously been set.

Setting the emulation version

And finally, we need to be able to set the emulation version.I've provided two functions for doing this, one which allows youto explicitly set a value, and another that uses the bestmatching value for the installed version of Internet Explorer.

As mentioned previously, I don't really want these functionscrashing for anticipated reasons, so these functions will alsocatch and ignore SecurityException andUnauthorizedAccessException exceptions. TheSetBrowserEmulationVersion function will return true if avalue was updated.

If you just want 'fire and forget' updating of the browseremulation version, you can use the following lines.

This will apply the best matching IE version if an emulationversion isn't set. However, it means if the user updates theircopy if IE to something newer, your application will potentiallycontinue to use the older version. I shall leave that as anexercise for another day!

Caveats and points to note

Changing the emulation version while your application is running

While experimenting with this code, I did hit a major caveat.

In the original application this code was written for, I wasapplying the emulation version just before the first windowcontaining a WebBrowser control was loaded, and this workedperfectly well.

However, setting the emulation version doesn't seem to work ifan instance of the WebBrowser control has already been createdin your application. I tried various things such as recreatingthe WebBrowser control or reloading the Form the control washosted on, but couldn't get the new instance to honour thesetting without an application restart.

The attached demonstration program has gone with the 'restartafter making a selection' hack - please don't do this inproduction applications!

Should I change the emulation version of my application?

You should carefully consider where or not to change theemulation version of your application. If it's currently workingfine, then it's probably better to leave it as is. If however,you wish to make use of modern standards compliant HTML, CSS orJavaScript then setting the appropriate emulation version willsave you a lot of trouble.

The are a lot of different options you can apply to InternetExplorer and the WebBrowser control. These options allow youto change behaviours, supported features and quite a few more.This article has touched upon one of the more commonrequirements, but there are a number of other options that areworth looking at for advanced application scenarios.

An index of all available configuration options can be found onMSDN.

Update History

  • 2014-06-28 - First published
  • 2020-11-21 - Updated formatting
FilenameDescriptionVersionRelease Date
IeBrowserEmulation.zip
  • md5: 565fb8296871228bd35c3b3daa58d187

Sample file for the article configuring the emulation mode of an Internet Explorer WebBrowser control

28/06/2014Download

While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?

MAHESH NARAYANAN V V

Great... Its Working Smoothly.. Thank you for your Post

İbrahim Uludağ

Very Thanks. Works perferctly.

chris devine

the usage command 'if (!InternetExplorerBrowserEmulation.IsBrowserEmulationSet()) { InternetExplorerBrowserEmulation.SetBrowserEmulationVersion(); }'

flags the 'InternetExplorerBrowserEmulation' as cannot resolve. Could you tell me what am doing wrong. All the other code has no errors

Salvatore

Edge

I at all and thanks for your code. It works fine for me but I have a little problem: when my app starts, IE show me a security message about the scripting ('to facilitate the security has been prevented to the file....'). How can I avoid this problem?

ShepSoft

Your article is unusual in that it is intelligently written and professionally presented - well done.

An additional (well known) issue with embedded IE is JS pop up errors. If you had time, a mention of this might be a useful extension to your excellent guide - you might mention the idea suggested by Ashot Muradian at http://stackoverflow.com/questions/6138199/wpf-webbrowser-control-how-to-supress-script-errors/18289217#18289217

Thank you.

Tolib Rahimov

Great solution! Thank you very much.

mansureh

Thank you very much, It helped me

Luis

Hey!, thanks for this code, i have a question.. all of you tried to show a pdf file inside webbrowser with this code??,.

i cant show a pdf inside of webbrowser, the webbrowser download the file and display on adobe reader desktop app, but without set the emulation mode it shows inside webbrowser.

The Danish

This seems to have been fixed in WPF, so instead of using Windows Forms try a WPF project.

ahmed

i got the message ' Failed to update browser emulation version .. Why ? and how can resolve it

som

This demo application is not working for me, js script error message always show for each browser version selection.

Christoph Bergner

Browser

Thank you Richard for the code. Do I understand right that the webbrowser control can only emulate a browser that is installed locally? I have a client who has IE 9 installed on all his machines - would using the webbrowser control emulating IE10 or 11 put him into place to access websites that require a higher version of IE, e.g. in order to use SVG features?

Евгений

Thank you so much. My WebBrowser control show me version 11, but I get error. I spend for it all day. After your post it work. Thank you so much again

Eddy Lai

C# Webbrowser For Edge

is it possible to make each emulation (IE9, IE10, IE11) use their own session cookie? now they share the same cookie with default Internet Explorer

Javi

Good Job!! Thank You

Damo

An excellent example, it is what I was looking for. Thank you for both an explanation and the sample! :-)

Justin

I've been doing this for a long time now and we recently upgraded to Windows 1809. This now blows up webpages in Outlook. Specifying 11001 or 11000 worked fine on Windows 1607. Now in Windows 1809 the pages act as if I opened IE and am going to the specified webpage using capability settings turned on. This naturally gives a garbled page. I'm wondering if there's new values I have to use above 11000. I can't seem to find official MS documention on this.

Yuli

For IE11 in WIN10 you need to look at IE minor version as well. In WIN10 minor version is != 0 while in older OS it's 0. If that's the case, you should set 11001 as the emulation version (BrowserEmulationVersion.Version11Edge).

Проголосовать сейчас

Описание редакции

Самый быстрый веб-браузер, какой когда-либо создавали Microsoft

Microsoft Edge считается самым быстрым браузером от Microsoft. Команда Edge сосредоточила все усилия на оптимизации производительности с того самого момента, как браузер впервые появился в составе Windows 10. Нельзя сказать, что он превосходит такого конкурента, как Chrome, однако по своим возможностям приближается к Safari, - а во многих аспектах работает еще лучше..Наряду с улучшенной скоростью работы (что, безусловно, является одним из важнейших параметров браузера), Edge предлагает другие полезные функции, добавленные Microsoft в последних обновления, в частности:Microsoft Edge позволяет вам делать пометки, когда вы просматриваете веб-страницы, и отмечать важные места прямо на сайтах. Кроме того, вы можете делиться этими заметками с друзьями, что может быть очень полезно, если вам нужно о чем-то сообщить коллегам в офисе или если вы хотите поделиться информацией с семьей и друзьями.

Скриншот


Сравнение альтернативных программ:


Авант Браузер - Avant Browser
Опера - Opera
Гугл хром - Google Chrome
Мозилла Фаерфокс - Mozilla Firefox
ОписаниеСтабильный многозадачный браузерБыстрый и надежный независимый интернет-браузер.Сверхбыстрый веб-браузер с беспрецедентным уровнем безопасности.Сверхскоростной веб-браузер с десятками дополнений.
Рейтингу
Загрузки174 4,311 4,291 5,134
Цена$ 0$ 0$ 0$ 0
Размер файла4.33 MB61.20 MB68.70 MB54.80 MB


Пользователи, которые скачивали Microsoft Edge Browser, также скачивали:

Мы рады посоветовать вам программы которые понравились другим пользователям Microsoft Edge Browser. Вот список программ, аналогичных Microsoft Edge Browser:

Скачать English Spanish, версия 1.0
Рейтинг пользователей
Webbrowser
Помогает переводчикам находить нужную информацию
Рейтинг пользователей
Скачать SearchMax, версия 3.0
Рейтинг пользователей
Получите подробную информацию о владельцах домена

C# Webbrower Edge

Рейтинг пользователей

Техническая информация
Рейтингу:5(1945)
Рейтинг в Интернет браузеры:202
Последняя оценка:
Лицензия:Бесплатная
Размер файла:0
Версия:Windows 10
Последнее обновление:29/7/2015
Операционная система:Windows XP, Windows Vista, Windows 8, Windows 7, Windows 10
Языки:Русский, Испанский, Немецкий, Английский, Индонезийский, Итальянский, Португальский, Польский, Турецкий, Чешский, Датский, Шведский, Китайский, Иврит, Арабский, Французский, Финский, Корейский, Норвежский, Хинди, Голландский, Японский, Греческий, Вьетнамский Больше..
Разработчик:Microsoft
Всего скачали (Русский):251
Всего скачали (По миру):73,369

C# Webbrowser Use Edge

Информация о разработчике

C# Webbrowser Edge Download

Имя разработчика:Microsoft
Количество программ по Microsoft:67
Популярные программы:
1. Windows Live OneCare
2. Байнг Мэпс - bing Maps
3. Microsoft Office Enterprise
4. Microsoft Expression Web
5. Microsoft Expression Studio 4
См. все 67 программы