您现在的位置:首页 --> JavaScript --> 用JavaScript判断IE版本号
用JavaScript判断IE版本号
浏览:2788次 出处信息
网上抄来的,找不到原文链接了。望告知。
// ---------------------------------------------------------- // 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天十大热文
-
[551] WordPress插件开发 -- 在插件使用 -
[89] 解决 nginx 反向代理网页首尾出现神秘字 -
[86] IOS安全–浅谈关于IOS加固的几种方法 -
[52] 到底什么是MVC? -
[48] 整理了一份招PHP高级工程师的面试题 -
[47] Linux Used内存到底哪里去了? -
[46] 二维码的生成细节和原理 -
[44] cookie窃取和session劫持 -
[43] 程序员技术练级攻略 -
[41] Shell的那些事儿
