Html 为什么 IE9 以文档模式打开为 IE7 标准?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13949858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why does IE9 opens in Document Mode as IE7 standards?
提问by Justin John
When I open a webpage in IE9 with DOCTYPE as
当我使用 DOCTYPE 在 IE9 中打开网页时
<!DOCTYPE html>
It opens Document Mode as IE7 standards.
它以 IE7 标准打开文档模式。
I need default IE9 standards on opening the page.
我需要在打开页面时使用默认的 IE9 标准。
How to correct this document mode problem?
如何更正此文档模式问题?
A screenshot of how it comes in IE browser developer tool
IE浏览器开发者工具中的截图
回答by Radim K?hler
Try this answer: https://stackoverflow.com/a/13524518/1679310.
试试这个答案:https: //stackoverflow.com/a/13524518/1679310。
Summary, give the IE browser more information in the meta tag:
总结,在meta标签中给IE浏览器更多的信息:
<!DOCTYPE html>
<html>
<head>
<title>My Web</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Edit Note: As Olly Hodgson mentioned, the proper option is IE=edge, as currently stated in the above snippet. Below is the original, also working version:
编辑注意:正如 Olly Hodgson 所提到的,正确的选项是 IE=edge,正如上面代码片段中目前所述。以下是原始的,也是工作版本:
<meta http-equiv="X-UA-Compatible" content="IE=100" />
回答by Tanzeel Kazi
There can be multiple reasons why it could be parsing the document under IE7 standard:
在 IE7 标准下解析文档可能有多种原因:
- The server is sending a
X-UA-Compatible
header for IE7 in the HTTP response of the document. Check the server response headers using a tool like Fiddler. - The HTML document is setting a meta tag with the
X-UA-Compatible
property value for IE7. - The page is being detected automatically by IE for opening in "Compatibility view". Note here that by default all intranet sites are viewed in "Compatibility view" in IE. Uncheck the checkbox "Display intranet sites in Compatibility view" under
Tools -> Compatibility view settings
in IE. The "Display all websites in Compatibility view" should be unchecked too. - You used the Developer tools and explicitly set to view the page to render in "IE7 standards" mode. Note that this will only occur on a per client basis though.
- 服务器正在
X-UA-Compatible
文档的 HTTP 响应中发送IE7的标头。使用类似Fiddler的工具检查服务器响应标头。 - HTML 文档正在
X-UA-Compatible
为 IE7设置具有属性值的元标记。 - 该页面正在被 IE 自动检测以在“兼容性视图”中打开。请注意,默认情况下,所有 Intranet 站点都在 IE 中的“兼容性视图”中查看。取消选中
Tools -> Compatibility view settings
IE下的“在兼容性视图中显示 Intranet 站点”复选框。“在兼容性视图中显示所有网站”也应该取消选中。 - 您使用了开发人员工具并明确设置为查看页面以在“IE7 标准”模式下呈现。请注意,这只会发生在每个客户端的基础上。
Update 2016-01-28
As @Gordon pointed out in the comments below, another reason can be that the network administrator has set the site for compatibility view as a Group Policy on the network.
The only resolution in that case is to contact the network administrator to remove the site from the Group Policy. See HTML1203 here.
更新 2016-01-28
正如@Gordon 在下面的评论中指出的那样,另一个原因可能是网络管理员已将站点的兼容性视图设置为网络上的组策略。
在这种情况下,唯一的解决方法是联系网络管理员以从组策略中删除该站点。请参阅此处的 HTML1203。
回答by Don Rolling
You can set this in the web.config as well.
您也可以在 web.config 中进行设置。
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
回答by Qpirate
Does your page contain the meta tag for forcing IE7?
您的页面是否包含强制 IE7 的元标记?
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
this will force the page to use IE7 compatibility.
这将强制页面使用 IE7 兼容性。
回答by Dev Blanked
Just wanted to share that if your web server is Apache2 you could set the Response header like below in your VirtualHost configuration which will also resolve the issue.
只是想分享一下,如果您的 Web 服务器是 Apache2,您可以在 VirtualHost 配置中设置如下所示的响应标头,这也将解决该问题。
Header set X-UA-Compatible "IE=edge"
回答by Jason Marsell
If your project is ASP.NET MVC, make sure that you add the:
如果您的项目是 ASP.NET MVC,请确保添加:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
tag into your Layout (template) page. I just spent two hours debugging and tweaking, only to realize that I had only added that meta tag into my child pages. As soon as I added it to my layout page, the browser loaded in EDGE mode perfectly.
标记到您的布局(模板)页面。我只花了两个小时调试和调整,才意识到我只是在我的子页面中添加了那个元标记。一旦我将它添加到我的布局页面,浏览器就会完美地以 EDGE 模式加载。
回答by Matt Connolly
The issue appears to be specific to the combination of IE9 and compatibility mode. For us, we cannot disable compatibility mode since it is a SharePoint 2013 site and IE11 must run in compatibility mode to edit pages, but IE9 was behaving as you are showing. Setting the X-UA-Compatible to "IE=edge" in a meta tag did fix our issue, although setting the value to IE=10 did not affect our behavior. We also have the same doctype.
该问题似乎特定于 IE9 和兼容模式的组合。对我们来说,我们无法禁用兼容模式,因为它是 SharePoint 2013 站点,并且 IE11 必须在兼容模式下运行才能编辑页面,但 IE9 的行为与您所显示的一样。在元标记中将 X-UA-Compatible 设置为“IE=edge”确实解决了我们的问题,尽管将值设置为 IE=10 并没有影响我们的行为。我们也有相同的文档类型。