Created
August 11, 2014 06:14
-
-
Save dvidsilva/4c8d9662d7142af9bb97 to your computer and use it in GitHub Desktop.
check the user agent to see if the browser is ios or android and add a class to the body
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
function isAppleDevice(){ | |
return ( | |
(navigator.userAgent.toLowerCase().indexOf("ipad") > -1) || | |
(navigator.userAgent.toLowerCase().indexOf("iphone") > -1) || | |
(navigator.userAgent.toLowerCase().indexOf("ipod") > -1) | |
); | |
} | |
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android"); | |
var appStoreURL = ""; | |
if(isAndroid > -1){ | |
$('body').addClass('android-device'); | |
} | |
else if( isAppleDevice() ){ | |
$('body').addClass('ios-device'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment