fro*_*dqy 6 javascript jquery jquery.support
目前我正在使用jQuery.browser来检测IE7和更低版本
if ($.browser.msie && parseInt($.browser.version) <= 7) {
//codes
}
Run Code Online (Sandbox Code Playgroud)
但是jQuery.browser在jQuery 1.3中被弃用并在jQuery 1.9中被删除,我从jQuery网站上读到我们应该使用特征检测(jQuery.support).
那么,如何使用jQuery.support检测IE7和更低?
Pra*_*man 10
最好的方法是使用条件注释并使用jQuery进行检查hasClass().
<!--[if lt IE 7]> <html class="ie6"> <![endif]-->
<!--[if IE 7]> <html class="ie7"> <![endif]-->
<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
在你的jQuery中,检查IE 7:
// Check IE 7
if ($('html').hasClass('ie7');
Run Code Online (Sandbox Code Playgroud)
无论如何,这种方法都不能被欺骗.另见:Paul Irish的Conditional Stylesheets.
| 归档时间: |
|
| 查看次数: |
8479 次 |
| 最近记录: |