Last active
July 14, 2016 06:30
-
-
Save weaming/f4ddada216c74a975b41 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
function checkBrowser(){ | |
var br={} | |
var ua=navigator.userAgent.toLowerCase(); | |
var s; | |
(s = ua.match(/chrome\/([\d.]+)/)) ? br.chrome = s[1] : | |
(s = ua.match(/firefox\/([\d.]+)/)) ? br.firefox = s[1] : | |
(s = ua.match(/msie ([\d.]+)/)) ? br.ie = s[1] : | |
(s = ua.match(/net.*rv:([\d.]+)/)) ? br.ie = s[1] : | |
(s = ua.match(/opera.([\d.]+)/)) ? br.opera = s[1] : | |
(s = ua.match(/version\/([\d.]+).*safari/)) ? br.safari = s[1] : 0; | |
var rt = ''; | |
if (br.ie) rt = 'IE: ' + br.ie; | |
if (br.firefox) rt = 'Firefox: ' + br.firefox; | |
if (br.chrome) rt = 'Chrome: ' + br.chrome; | |
if (br.opera) rt = 'Opera: ' + br.opera; | |
if (br.safari) rt = 'Safari: ' + br.safari; | |
return rt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment