您现在的位置:首页 --> JavaScript --> 用JavaScript判断IE版本号
用JavaScript判断IE版本号
浏览:2655次 出处信息
网上抄来的,找不到原文链接了。望告知。
// ---------------------------------------------------------- // A short snippet for detecting versions of IE in JavaScript // without resorting to user-agent sniffing // ---------------------------------------------------------- // If you're not in IE (or IE version is less than 5) then: // ie === undefined // If you're in IE (>=5) then you can determine which version: // ie === 7; // IE7 // Thus, to detect IE: // if (ie) {} // And to detect the version: // ie === 6 // IE6 // ie > 7 // IE8, IE9 ... // ie < 9 // Anything less than IE9 // ---------------------------------------------------------- // UPDATE: Now using Live NodeList idea from @jdalton var ie = (function(){ var undef, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i'); while ( div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', all[0] ); return v > 4 ? v : undef; }()); |
建议继续学习:
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
扫一扫订阅我的微信号:IT技术博客大学习
<< 前一篇:快速清除多选框的已选中状态
后一篇:更好的用vim浏览Javascript代码 >>
文章信息
- 作者:小寒 来源: 记事本
- 标签: 版本号
- 发布时间:2011-05-17 09:01:23
近3天十大热文
-
[882] WordPress插件开发 -- 在插件使用 -
[136] 解决 nginx 反向代理网页首尾出现神秘字 -
[57] 整理了一份招PHP高级工程师的面试题 -
[55] 分享一个JQUERY颜色选择插件 -
[54] Innodb分表太多或者表分区太多,会导致内 -
[54] 用 Jquery 模拟 select -
[54] 如何保证一个程序在单台服务器上只有唯一实例( -
[52] jQuery性能优化指南 -
[52] CloudSMS:免费匿名的云短信 -
[52] 海量小文件存储
