Skip to content

Instantly share code, notes, and snippets.

@dvidsilva
Created August 11, 2014 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvidsilva/4c8d9662d7142af9bb97 to your computer and use it in GitHub Desktop.
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
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