Skip to content

Instantly share code, notes, and snippets.

@jhammann
Created June 25, 2013 13:58
Show Gist options
  • Save jhammann/5858634 to your computer and use it in GitHub Desktop.
Save jhammann/5858634 to your computer and use it in GitHub Desktop.
Javascript code for checking if a user is on a mobile device. Mobile devices also include tablets. Remove 'iPad' if you do not want to include the iPad. Android serves all Android devices so you can't exclude a certain type.
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
// code here
} else {
// code here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment