views:

50

answers:

3

It seems that when the webpage has

<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />

so that IE 8 will emulate IE 7, then later in the webpage, when there is

<!--[if lt IE 8]> 
  <link href="http://www.example.com/stylesheets/compiled/ie.css" type="text/css" />
<![endif]-->

then it will also be loading ie.css?

That is, it is IE 8, emulating IE 7, and so the lt IE 8 will be true?

Update: but then, the server side variable HTTP_USER_AGENT will be still saying IE 8? Because the browser goes to the server as IE 8, gives IE 8 as the string of HTTP_USER_AGENT, and then the server replies with wanting to emulate IE 7. So if the server language such as PHP detects HTTP_USER_AGENT, it will still be IE 8 in the compatibility mode (IE 7 emulation mode)?

A: 

If you want a different solution (and are willing to use it), you can use jquery to detect the browser (jQuery.browser) . It does result with ie7 for ie8 in compatibility mode.

andyortlieb
+1  A: 

That's the whole point of that meta tag, isn't it? The moment you have this:

<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />

IE8 starts behaving on the client-side as IE7:

  • Your pages will all render as they would in IE7
  • Your conditional comments targeting anything older than IE8 (<!--[if lt IE 8]>) will also be read, and the code inside executed, so ie.css is loaded

However, the IE7 switch only takes place after IE8 reads that meta tag. Since your HTML is returned as part of the response, IE8 has to request it first. Since IE8 has no idea beforehand that this meta tag would appear, the user-agent string it sends is MSIE 8.0. PHP then recognizes it as IE8.

BoltClock
A: 

If you're telling ie8 to emulate ie7, you can trust that your css for ie7 should work right. Just use lte instead of lt.

<!--[if IE 8]> 
   <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />
<![endif]-->
<!--[if lte IE 8]> 
  <link href="http://www.example.com/stylesheets/compiled/ie.css" type="text/css" />
<![endif]-->
andyortlieb