Skip to content

Instantly share code, notes, and snippets.

@polarity
Created April 16, 2013 16:02
Show Gist options
  • Select an option

  • Save polarity/5397191 to your computer and use it in GitHub Desktop.

Select an option

Save polarity/5397191 to your computer and use it in GitHub Desktop.

Revisions

  1. polarity created this gist Apr 16, 2013.
    16 changes: 16 additions & 0 deletions detect.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    //Browsers
    var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/
    var IE7 = (document.all && !window.opera && window.XMLHttpRequest && navigator.userAgent.toString().toLowerCase().indexOf('trident/4.0') == -1) ? true : false;
    var IE8 = (navigator.userAgent.toString().toLowerCase().indexOf('trident/4.0') != -1);
    var IE9 = navigator.userAgent.toString().toLowerCase().indexOf("trident/5")>-1;
    var IE10 = navigator.userAgent.toString().toLowerCase().indexOf("trident/6")>-1;
    var SAFARI = (navigator.userAgent.toString().toLowerCase().indexOf("safari") != -1) && (navigator.userAgent.toString().toLowerCase().indexOf("chrome") == -1);
    var FIREFOX = (navigator.userAgent.toString().toLowerCase().indexOf("firefox") != -1);
    var CHROME = (navigator.userAgent.toString().toLowerCase().indexOf("chrome") != -1);
    var MOBILE_SAFARI = ((navigator.userAgent.toString().toLowerCase().indexOf("iphone")!=-1) || (navigator.userAgent.toString().toLowerCase().indexOf("ipod")!=-1) || (navigator.userAgent.toString().toLowerCase().indexOf("ipad")!=-1)) ? true : false;

    //Platforms
    var MAC = (navigator.userAgent.toString().toLowerCase().indexOf("mac")!=-1) ? true: false;
    var WINDOWS = (navigator.appVersion.indexOf("Win")!=-1) ? true : false;
    var LINUX = (navigator.appVersion.indexOf("Linux")!=-1) ? true : false;
    var UNIX = (navigator.appVersion.indexOf("X11")!=-1) ? true : false;