What is the difference between Browser Mode & Document Mode in IE



If you're a web developer and your job actively involves building web pages that work the same in all browsers including the last three versions of IE, you'll be no stranger to Browser  & Document Mode in Internet Explorer
These options are available with IE Developer Tools (F12 keyboard shortcut). In IE9, these modes let you emulate older versions of IE8 & IE7. Microsoft provides these modes so that websites that were built to target IE7 & lower versions don't fail hopelessly in the newer & more standards-based versions. IE provides a fallback in the form of the Compatibility View button which allows content designed for older web browsers to render well in newer versions of Internet Explorer 9. 

Here are the differences between Browser Mode & Document Mode -
Browser Mode determines the User Agent sent to the server & the Document Mode IE defaults to.
Document Mode determines the layout (rendering engine) and the JavaScript engine. Document Mode allows you to manually choose which rendering engine you want IE to render the page with; choosing the Internet Explorer 8 Standards mode uses the IE8 rendering engine, Internet Explorer 7 Standards Mode uses the IE7 rendering engine, or Quirks Mode uses the quirky, IE5.5 rendering engine. The Chakra JavaScript engine in IE9 is not the same as that shipped in IE8.

Changing the Browser Mode refreshes the page and  changes both the Document Mode and the User Agent string, which allows Internet Explorer to lie to a server about who it says it is.
Changing the Document Mode through IE’s Developer Tools refreshes the page, but does not resend the UA string or retrieve new markup from the server.

Sites cannot choose a Browser Mode.
Site developers can choose a Document Mode for their site, which overrides IE’s defaults and declares how a website is rendered. If a site does not specify a document mode then IE assumes the default document mode, which is IE9’s standards mode in IE9.

Here's how the User Agent string looks for different combinations of  Browser Mode & Document Mode in IE9 on a Windows 7 64-bit PC -
Browser Mode:IE9, Document Mode:IE9 standards
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

Browser Mode:IE9 Compat View, Document Mode:IE9 standards
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8)

Browser Mode:IE8, Document Mode:IE8 standards
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8)

Browser Mode:IE7, Document Mode:IE7 standards
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8)

Browser Mode:IE7, Document Mode:Quirks
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8)

Browser Mode:IE9, Document Mode:Quirks
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

Source: MSDN & StackOverflow

Related:
How IE determines Document Mode
Using X-UA-Compatible to Create Durable Enterprise Web Applications

Comments

  1. Why can you set Browser Mode to IE8 with Document Mode to IE9 Standards or higher? When would an IE8 browser ever render a doc with the IE9 javascript engine? Is that even possible?

    ReplyDelete

Post a Comment