Why IE8 is in IE7 mode. Variable "IE" == 7

3.2k views Asked by At

I have the header in my HTML page like this below and I open this site in IE8. When I look at it in "Web Developer" the "if IE 7" is active. WebBrowser set BrowserMode on "IE8 Compact VIew" and "Document Mode" on "IE7 standards". I have javascript on the site, which doesn't work good with these settings. Why does it happen? Why IE variable is equal 7? Why Browser is in these mode?

<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html lang="de" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="de" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="de" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="de" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="de" class="no-js"> <!--<![endif]-->
3

There are 3 answers

1
Spudley On BEST ANSWER

Others have recommended using X-UA-Compatible IE=8, but note that this will force IE to run in IE8 mode, even if the user has IE9 (or later). This is generally not what you're going to want.

Better to specify that IE should use the latest rendering engine available to it. For that, you use the same meta tag, but use IE=edge as the value, instead of IE=8.

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


Note that IE has a configuration panel which allows you to specify when it will use compatibility mode. For some reason, the default for this is to use compatibility mode for "sites in the local intranet".

This is the most common reason for IE jumping into compatibility mode unexpectedly when you're developing a site, as your localhost server will be treated as being "in the local intranet".

You can change this setting easily enough by going to the "Tools" menu, and picking the "Compatibility View Settings" option.

3
stevenrcfox On

You need to tell IE that the page does work with it

Try adding:

<!--Display in Native ie9 standards mode-->
<meta http-equiv="X-UA-Compatible" content="IE=9" >
<!--Display in Native ie8 standards mode-->
<meta http-equiv="X-UA-Compatible" content="IE=8" >
<!--Display in Native ie7 standards mode-->
<meta http-equiv="X-UA-Compatible" content="IE=7" >
0
Patrick Cavanaugh On

This post on the MSDN blog explains how Compatibility Mode can get enabled. There's a nice flowchart: http://blogs.msdn.com/b/ie/archive/2010/03/02/how-ie8-determines-document-mode.aspx

To fix it, you can also send the following HTTP header using a .htaccess file or whatever's appropriate for your web sever:

X-UA-Compatible: IE=8

Here's a reference on X-UA-Compatible: http://msdn.microsoft.com/en-us/library/cc288325%28VS.85%29.aspx