What's an up-to-date way for detecting IE?
Yeah, I'm rather new to this. Cheers!
Use conditional comments for IE6-9 and a little custom function for IE10. For example: HTML:
<!--[if lt IE 7 ]> <html class="ie6 ie"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7 ie"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8 ie"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9 ie"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
JS:
if ($('html').hasClass('ie') || (Function('/*@cc_on return document.documentMode===10@*/')())){
isIE = true;
}else{
isIE = false;
}
or you can just use:
if (Function('/*@cc_on return document.documentMode===10@*/')()){
document.documentElement.className+=' ie';
}
// Then..
if($('html').hasClass('ie')){...} // to check for IE10 and below.
Other answers focus on specifically detecting IE10 but I thought it would be helpful to show complete detection code in one place.