Skip to content

Instantly share code, notes, and snippets.

@Neferetheka
Created July 16, 2013 10:18
Show Gist options
  • Save Neferetheka/6007525 to your computer and use it in GitHub Desktop.
Save Neferetheka/6007525 to your computer and use it in GitHub Desktop.
Allows to detect common mobile platforms
isAndroid = function(){
return navigator.userAgent.toLowerCase().indexOf("android") > -1;
}
isIOS = function(){
return navigator.userAgent.match( /(iPod|iPhone|iPad)/ );
}
isWP = function(){
return navigator.userAgent.indexOf("Windows Phone OS") > -1;
}
isBB = function(){
return navigator.userAgent.match( /(PlayBook|BB10)/ );
}
isFOS = function(){
return navigator.userAgent.match( /(Mobile)/ ) && navigator.userAgent.match( /(Firefox)/ );
}
isMobile = function(){
return isAndroid() || isIOS() || isWP() || isBB() || isFOS();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment