Javascript – obter a versão do IE

Você pode obter a versão do IE desta função
(ps IE 10 não oferece suporte a comentários condicionais)

/**
* Get the major version of IE

* @params [ [integer] ]

* @return [integer || boolean]

* @reference James Padolsey <https://gist.github.com/527683>

*/

isIE
: function( version ) {
var
self = this.isIE,
ieVersion
= self.version;

ieVersion
= self.version = ( ieVersion !== undefined )? ieVersion
: (function(){
var
v
= 3, div, all,
isIE10
= ( eval("/*@cc_on!@*/false") && document.documentMode === 10 );

if ( isIE10 ) return 10;

div
= document.createElement('div'),
all
= div.getElementsByTagName('i');

while (
div
.innerHTML = '<!--[if gt IE ' + ( ++v ) + ']><i></i><![endif]-->',
all
[0]
){;}

return ( v > 4 )? v : false;
}());

return ( version )? version === ieVersion : ieVersion;
}

Exemplos

var ieVersion = isIE();
var isIE = !! isIE();
var isIE6 = isIE( 6 );
var isIE8 = isIE( 8 );
var isIE10 = isIE( 10 );

PS Obrigado galulex!