Created
October 3, 2018 20:08
-
-
Save moiseshilario/6a382341c36770b8dcfdb5a5e5e43998 to your computer and use it in GitHub Desktop.
Browser Detection
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 BrowserDetection() { | |
//Check if browser is IE | |
if (navigator.userAgent.search('MSIE') !== -1) { | |
console.log('IE'); | |
} | |
//Check if browser is Chrome | |
else if (navigator.userAgent.search('Chrome') !== -1) { | |
console.log('Chrome'); | |
} | |
//Check if browser is Firefox | |
else if (navigator.userAgent.search('Firefox') !== -1) { | |
console.log('Firefox'); | |
} | |
//Check if browser is Safari | |
else if (navigator.userAgent.search('Safari') !== -1 && navigator.userAgent.search('Chrome') === -1) { | |
console.log('Safari'); | |
} | |
//Check if browser is Opera | |
else if (navigator.userAgent.search('Opera') !== -1) { | |
console.log('Opera'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment