使用“X-UA-Compatible”模拟IE8用于IE8但不适用于IE9。 [英] Emulate IE7 for IE8 but not for IE9 using "X-UA-Compatible"

查看:116
本文介绍了使用“X-UA-Compatible”模拟IE8用于IE8但不适用于IE9。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个取决于矢量绘图的网站,对于Internet Explorer,我使用 VML

a>和其他浏览器,我正在使用 SVG
IE8但是,如果不回退到具有VML的IE7模式,则不支持这两种模式。

因此,我将< meta http-equiv =X-UA-Compatiblecontent =IE = EmulateIE7/>



(嗯,实际上是一件好事)是IE9现在支持SVG,所以我不希望它回退到性能和兼容性差得多的IE7模式。我如何才能告诉IE8回到IE7模式,但让IE9留在IE9模式?



现在我正在对代理进行服务器端检查是否在头部包含EmulateIE7字符串,但我希望尽可能避免这种情况。

解决方案

I

 < meta http-equiv =与X-UA兼容 content =IE = 7,IE = 9> 

这是逗号而不是分号!



我没有看过规范,但格式类似于适用于Chrome Frame的content =IE = 7,chrome = 1。我也发现内容=IE = 7,9的作品,但我怀疑这不是一个正确的格式。



编辑:



如果您的网页位于iframe中,请注意存在严重问题。如果您在 模式(小于IE9 strict)的框架页面中使用上述内容,那么 IE9将回退到IE8模式(忽略IE = 7请求!)。任何已知的解决方法欢迎:)可能与IE11无关。



以上这些似乎是设计特性的一个副作用,即iframe(和我认为是帧)要么全部处于IE9模式,要么全部小于IE9模式。人们不能将IE9帧与< IE9帧,请参阅MS问题#599022 #635648

编辑2:



请注意,IE11只支持IE =边缘(不是IE = 11),并且使用IE =边缘对IE有显着影响功能(包括用户代理)。

编辑3:


    < li>流程图,解释了IE如何解决IE9使用的模式IE8支持IE9支持IE $ edge, IE11。
  • Meta标签优先于HTTP标头(可以用来代替meta标签)
  • 还有一些 IE10的X-UA兼容信息



编辑4: $ b

X- UA兼容已从Microsoft Edge浏览器中删除。只有Internet Explorer具有兼容模式。请注意,如果您在Windows Phone 10的应用程序中使用WebView,那么您仍然在使用IE11(不是Edge)。



另外由于各种原因,您不能请相信用户代理告诉您正确的兼容级别,而是使用JavaScript中的 document.documentMode


I have a website depending on vector drawing, for Internet Explorer I'm using VML and for other browsers I'm using SVG. IE8 however, doesn't have support for neither without falling back to IE7-mode which has VML.

Therefore I'm including <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />.

The problem (well, actually a good thing) is that IE9 now has support for SVG so I don't want it to fall back to IE7-mode which has much worse performance and compatibility. How do I tell only IE8 to fall back to IE7-mode but let IE9 stay in IE9-mode?

Right now I'm doing a server side check on the agent whether to include the EmulateIE7-string in the head or not but I want to avoid this as far as it's possible.

解决方案

I just had a play and found the following works for me:

<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" >

That is with a comma not a semi colon!

I haven't looked at the spec, but the format is similar to content="IE=7,chrome=1" that works for Chrome Frame. I also found that content="IE=7,9" works but I suspect that is not a correct format.

Edit:

Beware of a serious problem if your page is in a iframe. If you use the above in a framed page where the parent is in any mode less than IE9 strict, then IE9 will fall back to IE8 mode (ignoring the IE=7 request!). Any known workarounds welcome :) Might not be relevant to IE11.

The above seems to be a side effect of the by design feature, that iframes (and I presume frames) are either all in IE9 mode, or all are less than IE9 mode. One can never mix IE9 frames with < IE9 frames, see MS issues #599022 and #635648.

Edit 2:

Beware that IE11 only supports "IE=edge" (not IE=11), and that using IE=edge has significant effects upon IE functionality (including the user agent).

Edit 3:

  • Fantastic flow chart explaining how IE works out what mode to use for IE9
  • IE=edge is supported by IE8 through to IE11.
  • The Meta tag takes precedence over the HTTP header (which can be used instead of the meta tag)
  • Some more X-UA-Compatible info for IE10.

Edit 4:

X-UA-Compatible was removed from the Microsoft Edge browser. Only Internet Explorer has the compatibility modes. Beware that if you are using the WebView within an App on Windows Phone 10, then you are still using IE11 (not Edge).

Also for a variety of reasons you cannot trust the user agent to tell you the correct compatibility level, instead use document.documentMode from JavaScript.

这篇关于使用“X-UA-Compatible”模拟IE8用于IE8但不适用于IE9。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆