检测 IE 的最新方法是什么?
- 条件注释不适用于
IE9, IE10 - modernizr 特征检测在这里没有帮助,因为原因是外部的(我想嵌入的 mapbox map 中的 IE 错误)
- jQuery + 迁移插件:如果有帮助,基本步骤是什么?
是的,我对此很陌生。干杯!
最佳答案
为 IE6-9 使用条件注释,为 IE10 使用一些自定义函数。例如: 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;
}
或者你可以只使用:
if (Function('/*@cc_on return document.documentMode===10@*/')()){
document.documentElement.className+=' ie';
}
// Then..
if($('html').hasClass('ie')){...} // to check for IE10 and below.
其他答案侧重于专门检测 IE10,但我认为在一个地方显示完整的检测代码会有所帮助。
关于jquery - 检测 <= IE10 的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17075828/