18

I want this for some conditional compilation code that will run in all IE's less than IE9.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Paul Irish
  • 47,354
  • 22
  • 98
  • 132
  • fwiw, conditional compilation will be in IE10's JScript engine. https://twitter.com/CarterRabasa/status/103241784137756673 – Paul Irish Aug 16 '11 at 16:57

3 Answers3

15

The check for less than IE9 is:

if (@_jscript_version < 9)

It's worth noting, the wikipedia crowd keeps these updated pretty well: http://en.wikipedia.org/wiki/Conditional_comment

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
4

It is almost always better to do feature detection, not specific version (or specific browser) detection, because there's no certainty that a given version of a browser is always the same.

For example, Microsoft will release a new mobile platform soon, with its own version of IE. In the past, the mobile versions of IE have sometimes reported exactly the same version data as the desktop versions, but they've had very different features and quirks between them.

I'd also suggest using jQuery, Modernizr, and other tools to make it easier to write code without having to worry about which browser you're on.

alex
  • 479,566
  • 201
  • 878
  • 984
Spudley
  • 166,037
  • 39
  • 233
  • 307
0

Hmmm, i too think that feature detection is the safest bet. you might also wanna keep an eye on the ecma support that particular jscript versions offer..

For IE 9 http://msdn.microsoft.com/en-us/ie/ff468705.aspx

And John resig's post.. ejohn.org/blog/versions-of-javascript/

Robin Maben
  • 22,194
  • 16
  • 64
  • 99