简体   繁体   English

运用 <meta http-equiv=“X-UA-Compatible” content=“IE=8” /> 网站模式的良好做法?

[英]Using <meta http-equiv=“X-UA-Compatible” content=“IE=8” /> mode in sites good practice?

I've recently discovered the joys of adding the following into the header of sites: 我最近发现了将以下内容添加到网站标题中的乐趣:

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

Websites just work, CSS is beautiful and life is good. 网站只是工作,CSS很漂亮,生活也很好。 But I am slightly concerned about how good a practice this is? 但我有点担心这种做法有多好?

What about an really old computer that has IE7 installed? 那台安装了IE7的旧电脑怎么样? Can that version of IE7 actually access the IE8 standards mode? 该版本的IE7能否实际访问IE8标准模式?

The short answer to the last part of your question is no: IE7 can't be made to work in IE8 mode. 对问题最后一部分的简短回答是否定的:IE7不能在IE8模式下工作。 So using the X-UA-Compatible header won't force older versions of IE to think they're a newer version. 因此,使用X-UA-Compatible标头不会强迫旧版本的IE认为它们是更新版本。 (if that worked, we could all just start using content="IE-10" and be done with worrying about backward compatibility forever) (如果有效,我们都可以开始使用content="IE-10"并且完全担心向后兼容性)

What the X-UA-Compatible flag does is tell newer versions of IE to fall back into compatibility mode to emulate older versions. X-UA-Compatible标志的作用是告诉较新版本的IE重新进入兼容模式以模拟旧版本。 So therefore, your content="IE-8" flag will have no effect on IE7 or IE8, but will make IE9 fall back into IE8 mode. 因此,您的content="IE-8"标志对IE7或IE8没有影响,但会使IE9回归到IE8模式。

This means that IE9 will effectively throw away its newer features, in the name of trying to be backward compatible. 这意味着IE9将以试图向后兼容的名义有效地丢弃其新功能。

If this is what you want from IE9, then by all means use the X-UA-Compatible header. 如果这是你想要的IE9,那么一定要使用X-UA-Compatible标头。 If it isn't what you want, then don't use it. 如果它不是你想要的,那就不要使用它。

(it's worth noting that the backward compatibility modes in IE are known to be not very good at being 100% compatible with real copies of the version they're trying to emulate, so don't think that you'll get a perfect copy of IE8 running in IE9 either -- it'll have it's own quirks that are different to either IE8 or IE9 in normal mode) (值得注意的是,已知IE中的向后兼容模式与他们试图模拟的版本的真实副本100%兼容并不是很好,所以不要认为你会获得完美的副本在IE9中运行的IE8也是如此 - 在普通模式下,IE8或IE9都有自己的怪癖

Another thing to be aware of is that the tag examples microsoft have provided don't always work. 另一件需要注意的事情是,微软提供的标签示例并不总是有效。 read defining document compatibility , especially the community additions at the bottom of the page. 阅读定义文档兼容性 ,尤其是页面底部的社区添加。

As far as best practice goes, they are probably not the best long term solution but came in very handy when IE9 was released and sites went down. 就最佳实践而言,它们可能不是最好的长期解决方案,但在IE9发布且网站出现故障时非常方便。

每个人都正确地说的向后兼容性应该仅在严格要求时应用,因为它不能完美地工作,并且不能通过添加兼容性标签来获得新浏览器的功能到旧浏览器。

I have IE8 installed in a Windows 7 test environment and it renders some parts of my code like IE7 did before (an there is no content="IE7" in my meta-tags)! 我在Windows 7测试环境中安装了IE8,并且它渲染了我的代码的一些部分,如IE7之前做过的(我的元标记中没有内容=“IE7” )!
On another machine with Windows 7 + IE8, the code is rendered different, but the way I want. 在使用Windows 7 + IE8的另一台机器上,代码呈现不同,但我想要的方式。
There's an interesting article at http://www.greywyvern.com/?post=313 telling that the way IE8 renders depends of the Service Pack installed on the system (the article is about XP, but mine is Windows 7 and I have the same issue). http://www.greywyvern.com/?post=313上有一篇有趣的文章告诉IE8呈现的方式取决于系统上安装的Service Pack(文章是关于XP的,但我的是Windows 7,我有同样的问题)。

So now I put content="IE10" on my webpages and my website is correctly displayed in IE10, IE9 and IE8. 所以现在我把content =“IE10”放在我的网页上,我的网站在IE10,IE9和IE8中正确显示。

I'm using Discus, it is not compatible with older versions of IE. 我使用的是Discus,它与旧版本的IE不兼容。 I got help they said to use content="IE-8" in my page code... 我得到了帮助他们说在我的页面代码中使用content =“IE-8”...

content="IE-8" also told my browser to change the sizes of tables and texts etc :p I changed to content="IE-7" it works perfect. content =“IE-8”也告诉我的浏览器改变表格和文本的大小等:p我改为content =“IE-7”它完美无缺。

Adding <meta http-equiv=“X-UA-Compatible” content=“IE=8” /> mode in not probably good idea since it will stop your application to take advantages of newer versions of browser. 添加<meta http-equiv=“X-UA-Compatible” content=“IE=8” />模式并不是一个好主意,因为它会阻止您的应用程序利用更新版本的浏览器。 But I think adding <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> is good since It forces the browser the render at whatever the most recent version's standards are. 但我认为添加<meta http-equiv="X-UA-Compatible" content="IE=Edge" />是好的,因为它会强制浏览器在任何最新版本的标准下呈现。

Note: Adding Edge can potentially break your code since your application might not be tested for this new version. 注意:添加Edge可能会破坏您的代码,因为您的应用程序可能未针对此新版本进行测试。 In most cases, this works absolutely fine, but you never know. 在大多数情况下,这非常好,但你永远不会知道。

For details about other possible options refer 有关其他可能选项的详细信息,请参

“X-UA-Compatible” content=“IE=9; “X-UA兼容”内容=“IE = 9; IE=8; IE = 8; IE=7; IE = 7; IE=EDGE” IE = EDGE”

暂无
暂无

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

相关问题 使用这个有什么问题吗? <meta http-equiv=“X-UA-Compatible” content=“IE=9” /> - Is there any issues using this? <meta http-equiv=“X-UA-Compatible” content=“IE=9” /> <meta http-equiv=“X-UA-Compatible” content=“IE=Edge” />在IE 11中无法正常工作 - <meta http-equiv=“X-UA-Compatible” content=“IE=Edge” /> is not working in IE 11 内容页面<meta http-equiv=“X-UA-Compatible” content=“IE=10”/> - Content page with <meta http-equiv=“X-UA-Compatible” content=“IE=10”/> 误解了<meta http-equiv=”X-UA-Compatible“ content=”IE=edge“> - Misunderstand of <meta http-equiv=”X-UA-Compatible“ content=”IE=edge“> 是否 <meta http-equiv=“X-UA-Compatible” content=“IE=Edge” /> 禁用条件? - Does <meta http-equiv=“X-UA-Compatible” content=“IE=Edge” /> disables conditionals? <meta http-equiv=“X-UA-Compatible” content=“IE=7” />该代码的作用是什么? - <meta http-equiv=“X-UA-Compatible” content=“IE=7” /> What does this code do? 做什么<meta http-equiv="X-UA-Compatible" content="IE=edge">做? - What does <meta http-equiv="X-UA-Compatible" content="IE=edge"> do? meta http-equiv =“X-UA-Compatible”content =“IE = edge”对非IE浏览器有影响吗? - Does meta http-equiv=“X-UA-Compatible” content=“IE=edge” impact on non-IE explorer? 如果我使用&#39;在Microsoft Edge浏览器上会出现渲染问题 <meta http-equiv=“X-UA-Compatible” content=“IE=7” /> &#39;? - Would rendering problems occur on Microsoft edge browser if I use '<meta http-equiv=“X-UA-Compatible” content=“IE=7” />'? IE 8仍在运行兼容模式,即使http-equiv =“ X-UA-Compatible” content =“ IE = edge,chrome = 1” - IE 8 still running compatibility mode even http-equiv=“X-UA-Compatible” content=“IE=edge, chrome=1”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM