Skip to content

Instantly share code, notes, and snippets.

@tbeseda
Last active December 11, 2015 10:48
Show Gist options
  • Save tbeseda/4589142 to your computer and use it in GitHub Desktop.
Save tbeseda/4589142 to your computer and use it in GitHub Desktop.
// Simple method to detect a mobile device
function isMobile(){
return (/iphone|ipod|android|blackberry/).test(navigator.userAgent.toLowerCase());
}
// Example usage:
if(isMobile()){
console.log('This is a mobile device.');
} else {
console.log('This is not a mobile device');
}
@argyleink
Copy link

nice, works great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment