Why IE8 is in IE7 mode. Variable “IE” == 7

老子叫甜甜 提交于 2019-12-02 01:32:14

问题


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]-->

回答1:


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.




回答2:


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




回答3:


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" >


来源:https://stackoverflow.com/questions/7754267/why-ie8-is-in-ie7-mode-variable-ie-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!