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

后端 未结 8 1519
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 07:36

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 with

相关标签:
8条回答
  • 2020-12-02 08:17
    <!--[if IE 8]>
      <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <![endif]-->
    

    It's called conditional comments
    http://en.wikipedia.org/wiki/Conditional_comment

    0 讨论(0)
  • 2020-12-02 08:24

    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">
    
    0 讨论(0)
提交回复
热议问题