[JavaScript] JS检测IE版本号 →→→→→进入此内容的聊天室

来自 , 2020-11-09, 写在 JavaScript, 查看 143 次.
URL http://www.code666.cn/view/b0dd033c
  1. // Credit goes to James Padolsey - http://james.padolsey.com
  2. // http://twitter.com/padolsey/status/21343465477
  3.  
  4. // ----------------------------------------------------------
  5. // If you're not in IE (or IE version is less than 5) then:
  6. //     ie === undefined
  7. // If you're in IE (>5) then you can determine which version:
  8. //     ie === 7; // IE7
  9. // Thus, to detect IE:
  10. //     if (ie) {}
  11. // And to detect the version:
  12. //     ie === 6 // IE6
  13. //     ie > 7 // IE8, IE9 ...
  14. //     ie < 9 // Anything less than IE9
  15. // ----------------------------------------------------------
  16.  
  17. var ie = (function(){
  18.  
  19.     var undef, v = 3, div = document.createElement('div');
  20.  
  21.     while (
  22.         div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',
  23.         div.getElementsByTagName('i')[0]
  24.     );
  25.  
  26.     return v > 4 ? v : undef;
  27.  
  28. }());
  29. //javascript/3949

回复 "JS检测IE版本号"

这儿你可以回复上面这条便签

captcha