With a bit of help from Dean Edwards, I worked out the following:
var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
(IE6 will be true in Internet Explorer 6 and under, but does anyone really care about IE5 anymore? Thought not.)
You could use this technique to sniff for other things:
// exactly Internet Explorer 7 var IE7 = false /*@cc_on || @_jscript_version == 5.7 @*/; // at least Internet Explorer 7 var gteIE7 = false /*@cc_on || @_jscript_version >= 5.7 @*/;// any Internet Explorer (thanks to Dean) var isMSIE = /*@cc_on!@*/false;
Note: browser sniffing is evil but sometimes painfully necessary.