tags:

views:

193

answers:

4

Title says it all.

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

+2  A: 

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
Interesting! I'm glad that IE will be keeping the JScript version in sync with the product version from now on.
Paul Irish
A: 

The Whole Thing is wrong

bob
...interesting answer :)
Nick Craver
In general I agree. That's why I develop a feature detection library called Modernizr. But there are some cases that are not detectable. And for those.. You need to do this. :)
Paul Irish
A: 

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/

conqenator
A: 

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 it's 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.

Spudley
Modernizr and jQuery are indeed quality products. :)
Paul Irish
Haha. Hey Paul, maybe if you try the contact forms on their webpages you could get in contact with a team member from one or both of those projects. I hear Paul Irish is on both teams, so he might be a good person to ask!
Alex Sexton