Last active
December 12, 2015 07:09
-
-
Save tmcw/4734909 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 detect() { | |
var browser = {}; | |
var ua = navigator.userAgent, | |
msie = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})"); | |
if (msie.exec(ua) !== null) { | |
var rv = parseFloat(RegExp.$1); | |
browser.support = !(rv && rv < 9); | |
} else { | |
browser.support = true; | |
} | |
browser.locale = navigator.language; | |
if (navigator.userAgent.indexOf('Win')) browser.os = 'win'; | |
else if (navigator.userAgent.indexOf('Mac')) browser.os = 'mac'; | |
else if (navigator.userAgent.indexOf('X11')) browser.os = 'linux'; | |
else if (navigator.userAgent.indexOf('Linux')) browser.os = 'linux'; | |
return browser; | |
}; | |
detect().os; | |
detect().locale; | |
detect().support; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment