2

Is there a way — for example with something like <!--[if IE 8]> — to get a stylesheet only for IE8 and IE in «Compatibly View»?

I ran into a (SharePoint-Layout-)Problem, which only occurs if IE8 is in «IE8 Compat View»-Browser-Mode, but works just fine if IE8 is «IE8»- or «IE7»-Browser-Mode. If I get the stylesheet only with <!--[if IE 8]>, the css will be ignored if IE8 is in compatibly view because it 'behaves like IE7' — the css will only be loaded if IE8 is in «IE8»-Browser-Mode. But I need it also if he is in the «IE8 Compat View»-Browser-Mode.

meo
  • 30,872
  • 17
  • 87
  • 123
albuvee
  • 2,744
  • 6
  • 28
  • 38
  • maybe this toppic helps you: http://stackoverflow.com/questions/1328963/detect-ie8-compatibility-mode – meo Dec 15 '10 at 13:40
  • 2
    Why would you need to do this? You decide which document mode your page runs in (by specifying a standards doctype or the X-UA-Compatible header). Just make sure your page doesn't load in compat view for IE 8. – Andy E Dec 15 '10 at 13:41
  • 2
    The compatibility mode is defined first and foremost by you, the author of the web page (by using the correct doctype, or the `X-UA-Compatible`) so you don't need to distinguish between the modes. If a user manually switches the mode for some reason, then it's his own fault if the site doesn't work anymore. – RoToRa Dec 15 '10 at 13:49
  • I disagree. If a developer is willing to cover more combinations and has the resources to achieve it, then more power to them. You can't snub users just because they don't follow your "expected" behavior. I hate Internet Explorer, and wish people never used it, but I will still code to those users. This is just an extension of that example. – D.N. Jan 28 '11 at 23:31

1 Answers1

0

See the SO post "Detect IE8 Compatibility Mode", in which user Mark Kamoski mentions the Microsoft article Defining Document Compatibility.

If you browse to the section Determining Document Compatibility Mode, you can use a test on document.documentMode (and document.compatMode for older browsers) to determine the mode. I don't know of how to roll this into a purely CSS implementation, but you can dynamically generate some CSS using some code to achieve this.

Community
  • 1
  • 1
D.N.
  • 2,160
  • 18
  • 26