Created
June 24, 2013 23:22
-
-
Save eccentricpixel/5854631 to your computer and use it in GitHub Desktop.
a way to detect what browser you are in just with javascript
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
var isOpera = !!window.opera || navigator.userAgent.indexOf('Opera') >= 0; | |
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera) | |
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ | |
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; | |
// At least Safari 3+: "[object HTMLElementConstructor]" | |
var isChrome = !!window.chrome; // Chrome 1+ | |
var isIE = /*@cc_on!@*/false; // At least IE6 | |
document.write('isFirefox: ' + isFirefox + '<br>'); | |
document.write('isChrome: ' + isChrome + '<br>'); | |
document.write('isSafari: ' + isSafari + '<br>'); | |
document.write('isOpera: ' + isOpera + '<br>'); | |
document.write('isIE: ' + isIE + '<br>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment