Created
July 26, 2012 02:48
-
-
Save neekey/3179966 to your computer and use it in GitHub Desktop.
获取浏览器信息
This file contains 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
var getBrowserInfo = function() { | |
var ua = navigator.userAgent; | |
// Ref: http://www.useragentstring.com/pages/useragentstring.php | |
var token = [ // 顺序有关 | |
"Opera", // 某些版本会伪装成 MSIE, Firefox | |
"Chrome", // 某些版本会伪装成 Safari | |
"Safari", // 某些版本会伪装成 Firefox | |
"MSIE 6", | |
"MSIE 7", | |
"MSIE 8", | |
"Firefox" | |
]; | |
for (var i = 0, len = token.length; i < len; ++i) { | |
if(ua.indexOf(token[i]) != -1) { | |
return token[i].replace(' ', ''); | |
} | |
} | |
return "Other"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment