Skip to content

Instantly share code, notes, and snippets.

@sgaurav
Created October 29, 2014 07:24
Show Gist options
  • Save sgaurav/d8aa7850fcdaf3319711 to your computer and use it in GitHub Desktop.
Save sgaurav/d8aa7850fcdaf3319711 to your computer and use it in GitHub Desktop.
Javascript method to detect browser without using UA String
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isFirefox = typeof InstallTrigger !== 'undefined';
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
var isChrome = !!window.chrome && !this.isOpera;
var isIE = false || !!document.documentMode;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment