Skip to content

Instantly share code, notes, and snippets.

@tetri
Last active October 2, 2025 18:46
Show Gist options
  • Select an option

  • Save tetri/7a363511f6858f0af9c2 to your computer and use it in GitHub Desktop.

Select an option

Save tetri/7a363511f6858f0af9c2 to your computer and use it in GitHub Desktop.
browser detection
// as seen on http://jsfiddle.net/9zxvE/383/
// and http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
// by http://stackoverflow.com/users/938089/rob-w
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 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 && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment