Browserswitch and then use meta http-equiv="X-UA-Compatible" - Documentmodus is already done

Go To StackoverFlow.com

1

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?

2012-04-05 15:59
by Joerg


5

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.

2012-04-12 13:59
by duri
Thank you! This is exactly was what i did anyway (making the whole stuff IE=8 , but i wanted to have the proof... i will read the link you gave me, then you get the bounty ;) thank - Joerg 2012-04-12 15:33
... it seems like IE6 is doing now really strange things (and before i switched everything to ie8 it worked..) i hate customers with old shitty browser - Joerg 2012-04-13 16:32
@Joerg Could you please show a demo website (on jsbin.com, for example) with both old and new markup and say what's the difference? X-UA-Compatible is certainly not supported in IE6 so you must have made a mistake somewhere else - duri 2012-04-13 16:49
the funny thing is: it makes now every bold text wrong, aber reloading a page its ok... but this was on EVERY request i did.. (but: this was a totally new installation of IE6 - after rebooting th computer it was going better...) strang stuff (and: sorry i can't provide it on jsbin (or jsfiddle) - i'm sure this will not happen on a normal page... but at the moment it works... so i don't care about the start problems (and it was not a cache problem, i deleted it before - Joerg 2012-04-14 17:56
Ads