3

I understand from my research that IE8 does annoying things like forcing itself into IE7 mode for local intranet hosts and local IP ranges. I understand from a previous question that there is no way to use conditional statements as, irrespective of whether IE8 is rendering in IE8 or IE7 mode, it will still only use the <!--[if IE 8]> conditional.

Since this question was asked a while ago (during the IE8 beta phase by the looks of things) I am wondering if this has changed or if there is any other way using conditionals to determine if IE8 is in compatibility mode.

Thanks!

Community
  • 1
  • 1
Konrad
  • 39,751
  • 32
  • 78
  • 114
  • possible duplicate of [How can I detect if IE8 is running in compatibility view?](http://stackoverflow.com/questions/1208837/how-can-i-detect-if-ie8-is-running-in-compatibility-view) – Pekka Jun 29 '10 at 11:21
  • Not dupe because I am specifically asking about using conditionals. – Konrad Jun 29 '10 at 11:23

3 Answers3

4

No, you can't do it using conditionals.

The best way to do it is to use the document.documentMode property as described in the link Pekka posted. How can I detect if IE8 is running in compatibility view?

Community
  • 1
  • 1
Nate Dudek
  • 1,245
  • 10
  • 12
-1

In the end, I chose to mix the two common strategies to deal with this bug.

I created an override CSS file, which I import using conditional comments. In the event of IE 8 or 9, though, this override doesn't look as good, so I include the 'force IE into latest rendering mode' header switch, as shown below.

<!--[if lte IE 7]>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <link rel="stylesheet" type="text/css" href="/Content/IE7Overrides.csss" />
<![endif]-->

This provides IE7 with a decent failsafe, but forces IE8 and IE9 to show it in the latest browser, which will show the CSS-based table correctly.

Jeff
  • 2,835
  • 3
  • 41
  • 69
  • As soon as you hit a conditional comment, IE determines what rendering mode it is in. Because of this, the nested meta tag will not work and will not set IE in edge mode. You can see a very long comment thread at HTML5BP's Github Repo about this issue: https://github.com/h5bp/html5-boilerplate/issues/378 – calvinf Apr 16 '13 at 00:57
  • @calvinf: Odd, because it's been working in production for several months. Something else must be going on that is plastering over the problem. – Jeff Apr 16 '13 at 12:26
  • are your pages setting X-UA-Compatible via an HTTP header? Additionally, pages without X-UA-Compatible will typically be rendered in edge mode unless your page is on one of Microsoft's IE compatibility view lists (or an intranet site). – calvinf Apr 16 '13 at 23:06
  • @calvinf: Honestly? I don't remember. I can't check, either, since I'm no longer at the company I worked for when I asked this question last year. – Jeff Apr 17 '13 at 12:57