所以我需要检测 IE 9。我知道我真的应该使用 feature detection但我不知道是什么功能导致了我的问题我所知道的是 Ie 9 导致了我的问题。
我已经解决了我的问题(对于那些感兴趣的人,我提出了一个关于该问题的问题 here 但实际上,这是无关紧要的)。
现在我只想为 IE9 实现这个 hack 修复,因为这才是让我头疼的原因。
那么检测 IE 9 的最佳方法是怎样的呢?
最佳答案
这些 IE 条件将为您提供一个 CSS 类来关闭:
<!--[if lt IE 7]> <html class="lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie10 lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie10 lt-ie9" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="lt-ie10" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html lang="en"> <!--<![endif]-->
因此,如果您只关心 IE9,您可以这样做:
<!--[if IE 9]> <html class="ie9" lang="en"> <![endif]-->
或者,为了符合惯例:
<!--[if IE 9]> <html class="lt-ie10" lang="en"> <![endif]-->
然后你的 JS(和 CSS)可以关闭 HTML.lt-ie10 选择器:
if ($('HTML.lt-ie10').length) {
//this is IE9 and older
}
else {
//this is not IE9 and older (so it could be Chrome, or Safari or IE10, etc)
}
关于jquery - 检测IE9而不进行功能检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17814486/