Emulate IE7 for IE8 but not for IE9 using “X-UA-Co

2019-01-10 05:57发布

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.

8条回答
看我几分像从前
2楼-- · 2019-01-10 06:03

This one works for IE9 to me.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
查看更多
小情绪 Triste *
3楼-- · 2019-01-10 06:11

I have so far used all these, nothing works on IE9:

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

<httpProtocol>
        <customHeaders>
          <clear />
          <add name="X-UA-Compatible" value="IE=EmulateIE8" />
        </customHeaders>
    </httpProtocol>

this is so frustrating, none of these meta tags seems to be working. Microsoft, What is so difficult in supporting stuff you say should work in your documentation? we have to spend hours doing browser wars. You are wasting everyone's time.

查看更多
Animai°情兽
4楼-- · 2019-01-10 06:11

Wow Microsoft have really created a nightmare here. We're going to be talking about this well into the future!

Anyway this works for me.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9" />
查看更多
甜甜的少女心
5楼-- · 2019-01-10 06:16

The dual mode mentioned by someone else should work (but doesn't as shown by Microsoft) and is the closest thing I've seen in MS documentation that should work as described. There's an update below that shows the proper form the meta attribute value should take.

So if you use this:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">

Unfortunately, what you will get is IE8 rendering as IE8 because of the fuzzy version vectoring that the x-ua-compatible engine does. See this document: Defining Document Compatibility: Understanding Content Attribute Values on MSDN. In that section, you'll see that in the first half, they define any version vector defined as larger than the current browser version will be interpreted as the largest available rendering engine. Therefore, emulateIE9 get's translated down to emulateIE8. Stupid.

Then, in the same breath practically, they talk about using multiple version vectors as in the code snippet above to exclude a particular engine. But because of the fuzzy version logic, that would never work. Ah, Microsoft. Fail again.

The reason why using CCs around the meta won't work, is that the browser must have chosen a rendering engine by the time it hits a CC. The x-ua meta must come before anything else in the header except other metas or the title according to MS's own documentation.

If anyone can figure this out, I'm all ears because I'm desperate to exclude IE8 from support while including IE9.

IMPORTANT UPDATE:

Robocat points out, using a comma instead of a semi-colon as Micrsoft shows is the correct way of doing this. I tested it and it worked for me. I've updated my test page.

So the correct form is this (as suggested by robocat):

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

The incorrect form is this (as suggested by Microsoft):

<meta http-equiv="X-UA-Compatible" content="IE=7; IE=9">
查看更多
做个烂人
6楼-- · 2019-01-10 06:16

I think what you need is:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">

according to http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx as it states this as "... an example that combines values so that IE8 renders a webpage in IE7 Standards mode while IE9 renders the webpage in IE9’s Standards mode:"

However I for one can't get this to work.

查看更多
再贱就再见
7楼-- · 2019-01-10 06:18

If you want IE 8 to use IE7 standards and IE 9 to use IE9 standards this one worked for me:

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

For IE9 this gives me IE 9 compatibility mode with IE 9 standards. For IE8 this gives me Browser Mode IE8 Document Mode IE7 Standards

查看更多
登录 后发表回答