Skip to content

Instantly share code, notes, and snippets.

@rpong
Last active August 29, 2015 14:06
Show Gist options
  • Save rpong/34c581166afd9c16d058 to your computer and use it in GitHub Desktop.
Save rpong/34c581166afd9c16d058 to your computer and use it in GitHub Desktop.
checkDevice
function checkDevice(mode) {
if (mode == 'ios') {
device = ['ipad', 'iphone', 'ipod'];
} else if (mode == 'android') {
device = ['android'];
}
var i = 0;
for ( ; i < device.length ; i++ ) {
if( navigator.platform.toLowerCase() == device[i]){
return true;
}
}
return false;
}
// usage:
// checkDevice("android");
// checkDevice("ios");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment