简体   繁体   English

如何修复IE 9中的文档模式重启

[英]How to fix Document mode restart in IE 9

I have a problem with opening my website in IE9. 我在IE9中打开我的网站时遇到问题。 When I try to open my site I get this error in dev tools: 当我尝试打开我的网站时,我在开发工具中遇到此错误:

HTML1113: Document mode restart from Quirks to IE9 Standards

I googled and found an answer that suggested to use this: 我用Google搜索并找到了一个建议使用此答案的答案:

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

or 要么

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

...but these do not work and I get the following message this time: ...但这些不起作用,这次我得到以下信息:

HTML1115: X-UA-Compatible META tag ('IE=Edge') ignored because document mode is already finalized.

What is my problem? 我的问题是什么? I read several articles like IE's Compatibility Features for Site Developers by Microsoft and traced my site with Determining IE9's Document Mode flowchart and use all suggestions relating to !doctype on these sites but no-one could solve my problem and my IE engine reset after the page opened. 我阅读了几篇文章,如IE的网站开发人员的兼容性功能,并通过确定IE9的文档模式流程图跟踪我的网站,并在这些网站上使用与!doctype相关的所有建议,但没有人可以解决我的问题,我的IE引擎重置后页面打开。

I develop my site with ASP.NET 4 on Windows Server 2008. How can I fix this issue? 我在Windows Server 2008上使用ASP.NET 4开发我的站点。如何解决此问题?

One solution that should always work is to put your X-UA-Compatible in HTTP headers. 一个应该始终有效的解决方案是将您的X-UA-Compatible放入HTTP标头中。 Also, your <!DOCTYPE> should be specified at the top of your HTML document ( <!DOCTYPE html> is the easiest one). 此外,您的<!DOCTYPE>应在HTML文档的顶部指定( <!DOCTYPE html>是最简单的)。

If you put your X-UA-Compatible declaration inside the meta tag you can run into the following problems: 如果将X-UA-Compatible声明放在meta标记内,则可能会遇到以下问题:

  1. X-UA-Compatible is ignored unless it's present inside the first 4k of you page. X-UA-Compatible被忽略,除非它出现在你页面的前4k内。 If you put it somewhere in the bottom of your head section (or in the body ) move it to top. 如果你把它放在head (或body )底部的某个地方,请将它移到顶部。 The best place for it is right after encoding and language declarations. 最好的地方就是编码和语言声明之后。
  2. X-UA-Compatible is ignored if it's put inside IE conditional comments. 如果将X-UA-Compatible放入IE条件注释中,则忽略它。 For example: 例如:

     <!--[if IE]> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <![endif]--> 

    In this case you should remove conditional comments. 在这种情况下,您应该删除条件注释。

  3. Also, you shouldn't have any text before the doctype declaration. 此外,在doctype声明之前,您不应该有任何文本。 If you've got any HTML comments there, for example, the IE will switch to quirks mode. 例如,如果你有任何HTML评论,那么IE将切换到怪癖模式。

  4. Finally, check if you're viewing this site from the intranet. 最后,检查您是否从Intranet查看此站点。 By default Compatibility View is enabled for Intranet sites. 默认情况下,为Intranet站点启用兼容性视图。

I suggest set X-UA-Compatible header for you page and then see if your site is still switching to quirks mode. 我建议为您设置X-UA-Compatible标题,然后查看您的网站是否仍在切换到怪异模式。 In that case you should check your markup and try to fix any HTML validator errors until it's back to Standards Mode. 在这种情况下,您应该检查您的标记并尝试修复任何HTML验证器错误,直到它返回到标准模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM