Skip to content

Instantly share code, notes, and snippets.

@iworkforthem
Created December 3, 2016 16:55
Show Gist options
  • Save iworkforthem/11b89fab9aa5ecebfd20ee06cc6711ba to your computer and use it in GitHub Desktop.
Save iworkforthem/11b89fab9aa5ecebfd20ee06cc6711ba to your computer and use it in GitHub Desktop.
detect browser types.
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment