Last active
August 29, 2015 14:07
-
-
Save wasim117/2261e2c3068ef9d282ad to your computer and use it in GitHub Desktop.
Get Operating system and browser using JavaScript
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
var os = (function() { | |
var ua = navigator.userAgent.toLowerCase(); | |
return { | |
isWin : /windows/.test(ua), | |
ismacOs : /mac os/.test(ua) | |
}; | |
}()); | |
var browser = (function() { | |
var ua = navigator.userAgent.toLowerCase(); | |
return { | |
isIE: /trident/.test(ua), | |
isFirefox: /firefox/.test(ua), | |
isChrome: /chrome/.test(ua), | |
isSafari: /safari/.test(ua), | |
}; | |
}()); | |
alert(os.isWin); | |
alert(os.isChrome); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment