Created
July 23, 2014 07:16
-
-
Save CooLNuanfeng/cf651dd3c356b7f99306 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 ie6=!-[1,]&&!window.XMLHttpRequest; //IE6为true,其他都为false | |
var isIE = !!window.ActiveXObject; //ie6-10都为true, ie11为false | |
/*返回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