Pregunta

We have some strange issue with some internet explorer versions, so we have a browser switch

<head>
<!--[if IE 6]>
  <!-- load some IE6 stuff -->
  <meta http-equiv="X-UA-Compatible" content="IE=6" />
<![endif]-->
<!--[if IE 7]>
  <!-- load some IE7 stuff -->
  <meta http-equiv="X-UA-Compatible" content="IE=6" />
<![endif]-->

<!--[if IE 8]>
  <!-- load some IE8 stuff -->
  <meta http-equiv="X-UA-Compatible" content="IE=8" />
<![endif]-->

<!--[if IE 9]>
  <!-- load some IE9 stuff -->
  <meta http-equiv="X-UA-Compatible" content="IE=8" />
<![endif]-->
</head>

If I load it like this, I see in the IE9 Developer add-on:

HTML1115: The X-UA-compatible META-Tag ("IE=8") was ignored, because the documentmodus was already loaded.

(originally its in german, so i this should be the translation)

and the document modus is still to IE9

If i wrote it hard into my <head> tags:

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

The IE9 is going to be loaded as IE8, so this works, but then the IE6 stuff of course is doing it wrong....

So is there any way to do it like i was first trying to do it?

¿Fue útil?

Solución

You can't do it such way. There's only limited number of things that can be used before X-UA-Compatible meta element.

The X-UA-Compatible header is not case sensitive; however, it must appear in the header of the webpage (the HEAD section) before all other elements except for the title element and other meta elements.

(from http://msdn.microsoft.com/en-us/library/ie/cc288325%28v=vs.85%29.aspx )

This is why your markup doesn't work as expected - conditional comment causes that all following X-UA-Compatible declarations are ignored.

Also note that X-UA-Compatible is supported only in IE8 and newer versions - it's completely ignored in IE6 and IE7. If you use only the following:

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

then IE6 and IE7 will use their own rendering and all versions from IE8 upwards will render the document as IE8.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top