Created
December 28, 2011 09:28
-
-
Save zhuangya/1527310 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 get_browser_info() | |
{ | |
var ua = navigator.userAgent.toLowerCase(); | |
var browser = ''; | |
var version = 0; | |
if(ua.indexOf('msie')>-1){ | |
browser = 'msie'; | |
version = ua.match(/msie ([\d.]+)/)[1]; | |
}else if(ua.indexOf('firefox')>-1){ | |
browser = 'firefox'; | |
version = ua.match(/firefox\/([\d.]+)/)[1]; | |
}else if(ua.indexOf('chrome')>-1){ | |
browser = 'chrome'; | |
version = ua.match(/chrome\/([\d.]+)/)[1]; | |
}else if(ua.indexOf('opera')>-1){ | |
browser = 'opera'; | |
version = ua.match(/opera.(\[d.]+)/)[1]; | |
}else if(ua.indexOf('safari')>-1){ | |
browser = 'safari'; | |
version = ua.match(/version\/([\d.]+).*safari/)[1]; | |
vjsid.js:42TypeError: 'null' is not an object (evaluating 'ua.match(/version\/([\d.]+).*safari/)[1]') | |
}else{ | |
browser = 'other'; | |
} | |
return browser+' '+version; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment