为什么IE8是IE7模式。变量“IE” == 7
我的 HTML 页面中有如下标题,我在 IE8 中打开该网站。 当我在“Web Developer”中查看它时,“如果 IE 7”处于活动状态。 WebBrowser 在“IE8 紧凑视图”上设置 BrowserMode,在“IE7 标准”上设置“文档模式”。 我的网站上有 javascript,但这些设置不能很好地工作。 为什么会发生这种情况?为什么IE变量等于7?为什么浏览器处于这些模式?
<!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]-->
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]-->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
其他人建议使用 X-UA-Compatible IE=8,但请注意,这将强制 IE 以 IE8 模式运行,即使用户使用 IE9(或更高版本)也是如此。这通常不是您想要的。
最好指定 IE 应使用可用的最新渲染引擎。为此,您可以使用相同的
meta
标记,但使用IE=edge
作为值,而不是IE=8
。请注意,IE 有一个配置面板,允许您指定何时使用兼容模式。由于某种原因,默认情况下对“本地 Intranet 中的站点”使用兼容模式。
这是当您开发站点时 IE 意外跳转到兼容模式的最常见原因,因为您的
localhost
服务器将被视为“在本地 Intranet 中”。您可以通过转到“工具”菜单并选择“兼容性视图设置”选项来轻松更改此设置。
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 useIE=edge
as the value, instead ofIE=8
.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.
MSDN 博客上的这篇文章解释了如何启用兼容模式。有一个很好的流程图: http://blogs.msdn.com/b/ie/archive/2010/03/02/how-ie8-determines-document-mode.aspx
要修复此问题,您还可以发送以下内容使用 .htaccess 文件或适合您的 Web 服务器的任何内容的 HTTP 标头:
以下是有关 X-UA 兼容的参考:http://msdn.microsoft.com/en-us/library/cc288325%28VS.85%29.aspx
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:
Here's a reference on X-UA-Compatible: http://msdn.microsoft.com/en-us/library/cc288325%28VS.85%29.aspx
您需要告诉 IE 该页面确实可以使用它
尝试添加:
You need to tell IE that the page does work with it
Try adding: