Skip to content

Instantly share code, notes, and snippets.

@Kaapiii
Created April 26, 2013 13:11
Show Gist options
  • Save Kaapiii/5467275 to your computer and use it in GitHub Desktop.
Save Kaapiii/5467275 to your computer and use it in GitHub Desktop.
Javascript navigator
if( navigator.userAgent.match(/iPhone/i) ) this.webkit_css_enabled = true;
else if( navigator.userAgent.match(/iPod/i) ) this.webkit_css_enabled = true;
else if( navigator.userAgent.match(/iPad/i) ) this.webkit_css_enabled = true;
else if( navigator.userAgent.match(/Chrome/i) ) this.webkit_css_enabled = true;
else if( navigator.userAgent.match(/Safari/i) ) this.webkit_css_enabled = true;
// check for certain platforms
if( navigator.userAgent.match(/Android/i) ) this.is_android = true;
if( navigator.userAgent.match(/Android 2.1/i) ) this.is_android21 = true;
if( navigator.userAgent.match(/Android 2.2/i) ) this.is_android22 = true;
if( navigator.userAgent.match(/MSIE/i) ) this.is_msie = true;
if( navigator.userAgent.match(/MSIE 6/i) ) this.is_msie6 = true;
if( navigator.userAgent.match(/MSIE 8/i) ) this.is_msie8 = true;
if( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i) ) this.is_idevice = true;
if( navigator.userAgent.match(/Firefox/i) ) this.is_firefox = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment