0

I was wondering when I put my browser in compatibility mode, how does it know what setting to use from the header tags found in the document. If we have logic for all versions back to EI7, will it use the furthest back? So in this case, it chooses 7 in comp mode, but if we only offered back to IE8, then it would choose IE8 for that instance? So the question is, why does IE 11 compatibility mode set it to IE7 standards according to my debugger in IE? If I remove the [if IE7] code snippet, will it then set it to IE8 standards in the browser? We just quit supporting IE7 so am why I am asking this.

[if IE 7 ]>    <html class="ie7"
[if IE 8 ]>    <html class="ie8" 
[if IE 9 ]>    <html class="ie9"
Simba
  • 4,952
  • 3
  • 19
  • 29
Casey ScriptFu Pharr
  • 1,672
  • 1
  • 16
  • 36
  • 1
    Did you try testing it in your browser? Seems like you could answer your own question very easily. – Sam Hanley Nov 18 '15 at 16:02
  • Trying, but that is the problem. It was stating when I opened in IE comp mode, in the console of the debugger, attached page targets document mode IE7. After taking it out, it is stating that it is invalid document type. So does IE comp mode always try to put it into IE7 mode? – Casey ScriptFu Pharr Nov 18 '15 at 16:06
  • The code you've quoted for setting the mode is incomplete; it won't work at all in the form you've got in the question. – Simba Nov 18 '15 at 16:13

2 Answers2

1

The code you've quoted in the question does NOT tell IE what mode to use. What this code does is look at the mode that IE is already in, and react accordingly.

Therefore, the answer to your question is: No: Removing the IE7-specific block from this code will not stop IE going into IE7 mode.

If you want to force IE to go into a specific mode, the code you need to use is the X-UA-Compatible meta tag.

You need a line near the top of you HTML that looks like this:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

Putting edge in the content tells IE to use it's best available mode (so IE11 will be in IE11 mode). If you want a specific IE mode, then put IE8 or similar instead of edge.

Simba
  • 4,952
  • 3
  • 19
  • 29
  • Thanks, and that is what I was wanting to know. So doesn't it seem, that if we stopped supporting IE7, we should apply this to all of our page headers since we tell our end users to use compatibility mode all the time, and that puts it into IE7 mode? – Casey ScriptFu Pharr Nov 18 '15 at 17:22
1

In addition, the way you view your pages also affects the document mode.

  • If you view a page on the Internet (or through a local web browser), the page opens in the Internet zone. In this case, the x-ua-compatible directive takes precedence; depending on the setting, the <DOCTYPE> may also have an impact.
  • If you open the page using the File menu, from File Explorer, or from a network path, the page opens in the Intranet zone. By default, this means your page opens in IE7 compatibility mode, though that can be changed through settings.
  • Apps hosting the webBrowser control default to IE7 unless you override that using a registry change. (Note, it's currently unclear whether this is supported in Windows 10).

For best results:

  1. Use the HTML5 <DOCTYPE> directive.
  2. Use an x-ua-compatible meta with content set to IE=edge.
  3. View local pages through a local webbrowser.
  4. Code for HTML5, detect features, provide graceful fallback, and worry less about individual differences between individual browsers.

Hope this helps...

-- Lance

Community
  • 1
  • 1
Lance Leonard
  • 3,285
  • 3
  • 16
  • 15
  • The problem is that I just started at a new company, and they just stopped supporting IE8. Though, they tell all of their agents to use IE comp mode all the time for the web applications, and it just so happens, it puts them into IE7 standard mode. Doesn't make sense to me. – Casey ScriptFu Pharr Nov 18 '15 at 17:20
  • If by "compatibility mode," you mean "compatibility view," then that's the documented behavior. Compatibility view is what Defining Document Compatibility defines as EmulateIE7 mode, meaning that the browser goes into IE7 standards if given a standards mode doctype (like the HTML5 doctype) or it goes into IE5 quirks mode. It's a knee-jerk reaction that leads to few good resolutions. – Lance Leonard Nov 19 '15 at 02:05
  • So why would we then still be developing for comparability view, but not supporting IE7? Is that not going to give an accurate outcome then? – Casey ScriptFu Pharr Nov 30 '15 at 16:10