IE8 browser mode vs document mode
Asked Answered
B

4

72

Can someone please explain the difference between IE8 browser mode and document mode in simple terms?

  • What causes the browser mode to change?
  • What causes the document mode to change?

  • If a user changes the mode(s) via developer tools, does the change remain even if the page is refreshed?

I am asking this because we are doing some IE8 testing here, and different people have different combinations of the modes, and i want to try to figure out how this is happening.

Botryoidal answered 1/6, 2010 at 14:27 Comment(3)
See also stackoverflow.com/questions/6661313Plutonium
All this document mode thing seems to make no sense at all. For instance, in the dev tool I can set a document mode of IE9 with a browser mode of IE8. Why not let us modify the browser mode only?Etching
@AdrienBe did you find that a lot of things in IE make sense prior to this experience?Botryoidal
O
69

From this article on the IE8 blog, entitled How IE8 Determines Document Mode

  1. The Developer Tools settings override all Document Modes for pages displayed in a tab.
  2. The X-UA-Compatible meta tag and then header override Compatibility View Settings and the doctype unless the X-UA-Compatible value is EmulateIE7 or EmulateIE8.
  3. The user’s Compatibility View Settings override the Microsoft Compatibility View List.
  4. If none of the above rules apply, the doctype determines whether the webpage renders in IE8 Standards, IE8 Almost Standards or Quirks Mode.

So from that we get the following answers to your questions:

Q. What is the difference between browser mode and document mode in simple terms?
A. Browser mode is set in the developer tools to emulate different IE browser version behaviors while document mode is defined on the web page to tell IE to render the site differently for compatibility purposes.

Q. What causes the browser mode to change?
A. The user changes the browser mode in the dev tools.

Q. What causes the document mode to change?
A. The Doctype and the X-UA-Compatible meta tag and header set by the web developer.

Q. If a user changes the mode(s) via developer tools, does the change remain even if the page is refreshed?
A. The Browser Mode will stay, but if you change the Doctype and X-UA-Compatible, they will go back to what is defined on the page.

UPDATE: As Adrien Be points out below, IE9+ adds the ability to change the document mode in the dev tools via a setting which will persist on refresh.

Olga answered 1/6, 2010 at 14:45 Comment(4)
Thanks for the summary. Its the first time ive seen that diagram.. no wonder i felt like i might have missed something.Botryoidal
msdn.microsoft.com/en-us/library/dd565628(VS.85).aspx#bdmodes has some more info too.Odaniel
Not too sure if this answer is correct as it says "document mode is defined on the web page to tell IE to render the site differently for compatibility purposes" when it can also be modified in the developer tool (for IE9 and IE10 that's for sure anyway).Etching
@AdrienBe They added the ability to change document mode in the dev tools of IE9. IE8 (which is the subject of the question) did not have a document mode toggle in the dev tools. Having said that, I will add a foot note to the bottom since this question still get quite a bit of traffic from people who are likely wondering about IE9+.Olga
D
17

See your answer in this page.

The documentMode property returns the mode used by the browser to render the current document.

IE8 can render a page in different modes, depending on the !DOCTYPE or the presence of certain HTML elements.

This property returns one of following values:

5 - The page is displayed in IE5 mode
7 - The page is displayed in IE7 mode
8 - The page is displayed in IE8 mode
9 - The page is displayed in IE9 mode

Note: If no !DOCTYPE is specified, IE8 renders the page in IE5 mode!

Diagram of the document mode selection process

Dourine answered 7/1, 2013 at 9:54 Comment(1)
Upvote for the diagram. Majorly complicated to figure out otherwise.Overstuff
W
3

Browser Mode: Specifies the user agent sent by the browser to the Web Server. Rendering differences can occur if your JavaScript or back-end code renders differently based on the user agent string. For example, you may see JavaScript that checks navigator.userAgent. (Mozilla/5.0 (compatible; MSIE 8.0...) This value is also used to to process conditional comments ([if lte IE 9], [if gt IE 8], etc.). The Emulation tooling in IE 11 does not have a browser mode. It has a user agent drop-down instead.

Document Mode: Specifies the rendering engine used to process the markup. This is typically where we see rendering issues and browser incompatibilities. The original goal (for better or worse) was website owners could choose a document mode for their site via a meta tag. In IE 11, the emulation tools are less confusing.

Testing: If your goal is to emulate an old IE8 browser, you should change both browser mode and document mode. The emulation is not perfect, so a more thorough option is to download free test VMs from Microsoft where you can test with a *real" version of IE 8, 9, etc.

What causes these values to change?

The Browser mode will not change. (Unless you change it in Dev tools.) It is set before making the request to the web server.

The document mode can change based on web server response. It can be changed via a X-UA-Compatible HTTP response header, the doc type, meta tags, Intranet sites, markup issues, etc.

Whizbang answered 26/8, 2014 at 19:57 Comment(0)
M
0

There is a little button in top left , in IE dev tools -> emulation (tab) that says "Persist emulation settings"

see this :

"Settings persistence and reset A Persist Emulation settings icon is added to the Emulation tool. This will maintain your current emulation settings until specifically disabled, allowing you to work, close the browser, and come back with your emulation settings intact. To its right is a Reset Emulation settings icon, which quickly resets the tool back to default values."

Michaelemichaelina answered 30/1, 2016 at 12:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.