Html 如何强制 IE10 在 IE9 文档模式下呈现页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14382636/
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
How to force IE10 to render page in IE9 document mode
提问by Amit
I have two questions:
我有两个问题:
How can I force IE10 to render in IE9 document mode? Currently it's rendering my page in Standard document mode.
In IE10's developer toolbar, I am not able to see the option of document mode of IE10. Is it not implemented, or is my browser version is out of date?
如何强制 IE10 在 IE9 文档模式下呈现?目前它以标准文档模式呈现我的页面。
在IE10的开发者工具栏中,我看不到IE10的文档模式选项。是没有实现,还是我的浏览器版本过时了?
Thanks for all your help.
感谢你的帮助。
Edit: thanks everyone for the solutions provided. Earlier I was using a meta tag
<meta http-equiv="x-ua-compatible" content="IE=edge" >
just to make sure that IE will render the page in highest document mode, but I was facing some issues with IE10 standard mode, so I changed the meta tag to render the page in IE9 mode:
<meta http-equiv="x-ua-compatible" content="IE=9" >
.
编辑:感谢大家提供的解决方案。早些时候,我使用元标记
<meta http-equiv="x-ua-compatible" content="IE=edge" >
只是为了确保 IE 将在最高文档模式下呈现页面,但我在 IE10 标准模式下遇到了一些问题,因此我更改了元标记以在 IE9 模式下呈现页面:
<meta http-equiv="x-ua-compatible" content="IE=9" >
.
回答by Shauna
You should be able to do it using the X-UA meta tag:
您应该能够使用X-UA 元标记来做到这一点:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
However, if you find yourself having to do this, you're probably doing something wrong and should take a look at what you're doing and see if you can do it a different/better way.
但是,如果您发现自己必须这样做,那么您可能做错了什么,应该看看您在做什么,看看您是否可以用不同的/更好的方式来做。
回答by Paul D. Waite
Do you mean you want to tell your copy of IE 10 to render the pages it views in IE 9 mode?
您的意思是要告诉您的 IE 10 副本呈现它在 IE 9 模式下查看的页面吗?
Or do you mean you want your website to force IE 10 to render it in IE 9 mode?
或者您的意思是您希望您的网站强制 IE 10 在 IE 9 模式下呈现它?
For the former:
对于前者:
To force a webpage you are viewing in Internet Explorer 10 into a particular document compatibility mode, first open F12 Tools by pressing the F12 key. Then, on the Browser Modemenu, click Internet Explorer 10, and on the Document Modemenu, click Standards.
http://msdn.microsoft.com/en-gb/library/ie/hh920756(v=vs.85).aspx
要强制您在 Internet Explorer 10 中查看的网页进入特定的文档兼容模式,请先按 F12 键打开 F12 工具。然后,在浏览器模式菜单上,单击Internet Explorer 10,然后在文档模式菜单上,单击标准。
http://msdn.microsoft.com/en-gb/library/ie/hh920756(v=vs.85).aspx
For the latter, the other answers are correct, but I wouldn't advise doing that. IE 10 is more standards-compliant (i.e. more similar to other browsers) than IE 9.
对于后者,其他答案是正确的,但我不建议这样做。IE 10 比 IE 9 更符合标准(即更类似于其他浏览器)。
回答by PlantTheIdea
I haven't seen this done before, but this is how it was done for emulating IE 8/7 when using IE 9:
我以前从未见过这样做过,但这是在使用 IE 9 时模拟 IE 8/7 的方式:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
If not, then try this one:
如果没有,那么试试这个:
<meta http-equiv="X-UA-Compatible" content="IE=9">
Add those to your header with the other meta tags. This should force IE10 to render as IE9.
将这些与其他元标记一起添加到您的标题中。这应该强制 IE10 呈现为 IE9。
Another option you could do (assuming you are using PHP) is add this to your .htaccess
file:
您可以做的另一个选择(假设您使用的是 PHP)是将其添加到您的.htaccess
文件中:
Header set X-UA-Compatible "IE=9"
This will perform the action universally, rather than having to worry about adding the meta tag to all of your headers.
这将普遍执行操作,而不必担心将元标记添加到所有标题。
回答by Vinod K
You can tweak the Registry if you want to make changes only to your own system. If you have IE10 and lots of web sites you visit don't render properly in IE10, then you can tweak your registry to force IE to open in IE9 mode.
如果您只想对自己的系统进行更改,则可以调整注册表。如果您有 IE10 并且您访问的许多网站无法在 IE10 中正确呈现,那么您可以调整您的注册表以强制 IE 在 IE9 模式下打开。
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
Create a DWORD as iexplore.exe
and give value 9999
. Restart your IE and it will open in IE9 mode :)
创建一个 DWORD asiexplore.exe
并给出 value 9999
。重新启动您的 IE,它将以 IE9 模式打开 :)
Thanks to my colleague Sreejith D :)
感谢我的同事 Sreejith D :)
回答by Ragnarokkr
By what thissays, IE10 (the article is referred to a preview release, anyway) it's able to use X-UA-Compatible
onlyif the document is in quirks mode (no DOCTYPE
), otherwise IE10 won't react to the request.
凭什么这样说,IE10(本文称为一个预览版本,反正)它能够使用X-UA-Compatible
仅如果文档中的怪癖模式(无DOCTYPE
),否则IE10将不作出反应的要求。
Here's an excerpt:
这是摘录:
Thus, to make IE10 react to the X-UA-Compatible directive, one must either create a page that triggers quirks-mode per the rules of HTML5 (that is: an a page with no doctype). One can also send the directive as a HTTP header, however: A HTTP sent directive appears to have no effect if you use it to downgrade the rendering — it can only be used to upgrade the rendering
因此,为了使 IE10 对 X-UA-Compatible 指令做出反应,必须创建一个根据 HTML5 规则触发 quirks-mode 的页面(即:一个没有 doctype 的页面)。也可以将指令作为 HTTP 标头发送,但是:如果您使用 HTTP 发送指令来降级渲染,则它似乎无效——它只能用于升级渲染
So, you've to do it manually with Dvelopers Tools, or with quirks mode (but I suggest to stay in IE10 mode which is for the first timealigned to the other browers' standard)
因此,您必须使用 Dvelopers Tools 或 quirks 模式手动执行此操作(但我建议保持 IE10 模式,这是第一次与其他浏览器的标准保持一致)
EDIT: The follows are some useful link to read:
编辑:以下是一些有用的链接:
http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx
http://blogs.msdn.com/b/ie/archive/2011/12/14/interoperable-html5-quirks-mode-in-ie10.aspx
http://blogs.msdn.com/b/ie/archive/2011/12/14/interoperable-html5-quirks-mode-in-ie10.aspx
回答by Bart
回答by Shawn Xue
there are many ways can do this:
有很多方法可以做到这一点:
add X-UA-Compatible tag to head http response header
添加 X-UA-Compatible 标签到 head http 响应头
using IE tools F12
使用 IE 工具 F12
change windows Registry
更改 Windows 注册表
回答by Ana Sampaio
I found this post while I was looking for a solution to my DNN6 website. The error was
我在寻找 DNN6 网站的解决方案时发现了这篇文章。错误是
SCRIPT5007: Unable to get property 'documentElement' of undefined or null reference
SCRIPT5007:无法获取未定义或空引用的属性“documentElement”
But I needed the same solution: force compability mode to IE9. So let me share with you what I did to solve this.
但我需要相同的解决方案:强制兼容模式到 IE9。因此,让我与您分享我为解决此问题所做的工作。
So, for DotNetNuke 6 users try the StyleHelper SkinObject
因此,对于 DotNetNuke 6 用户,请尝试使用StyleHelper SkinObject
Worked great for me!
对我来说很棒!
回答by Sreejith. D. Menon
The hack is recursive. It is like IE itself uses the component that is used by many other processes which want "web component". Hence in registry we add IEXPLORE.exe
. In effect it is a recursive hack.
黑客是递归的。这就像 IE 本身使用了许多其他需要“Web 组件”的进程所使用的组件。因此在注册表中我们添加IEXPLORE.exe
. 实际上,它是一个递归黑客。