Created
July 16, 2013 10:18
-
-
Save Neferetheka/6007525 to your computer and use it in GitHub Desktop.
Allows to detect common mobile platforms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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