Created
July 15, 2014 03:28
-
-
Save hehongwei44/979dcbaa18d315107383 to your computer and use it in GitHub Desktop.
用户代理的一些小技巧
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * @link :http://browserhacks.com/ | |
| * IE篇 | |
| */ | |
| var isIE = document.all && !window.XMLHttpRequest; //IE6为true,其他都为false | |
| var isIE = !!window.ActiveXObject; //ie6-10都为true, | |
| var isIE = document.all && document.compatMode; //ie6-10都为true, | |
| /*返回IE6-9的版本号*/ | |
| var _IE = (function(){ | |
| var 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 : false ; | |
| }()); | |
| /* | |
| * @link :http://browserhacks.com/ | |
| * chrome篇 | |
| */ | |
| var isChromium = !!window.chrome; //Chromium为true. | |
| var isChrome = !!window.chrome && !!window.chrome.webstore; //chrome为true. | |
| /* | |
| * @link :http://browserhacks.com/ | |
| * Firefox篇 | |
| */ | |
| var isFF = !!window.sidebar; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment