Created
September 17, 2013 22:31
-
-
Save make-sum/6601585 to your computer and use it in GitHub Desktop.
Detect if device is Android, iPhone, iPad, or iPod.
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
var isMobile; | |
var is_uiwebview = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent); | |
var is_safari_or_uiwebview = /(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent); | |
var ua = navigator.userAgent.toLowerCase(); | |
var isAndroid = ua.indexOf( "android") > -1; | |
if ( isAndroid || is_uiwebview || is_safari_or_uiwebview ) { | |
isMobile = true; | |
//do something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment