Skip to content

Instantly share code, notes, and snippets.

@bspingarn
Created March 19, 2012 19:49
Show Gist options
  • Save bspingarn/2125777 to your computer and use it in GitHub Desktop.
Save bspingarn/2125777 to your computer and use it in GitHub Desktop.
Javascript - mobile phone detection excluding tablets
//this 100% isnt accurate due to android browser unreliably reporting width.. use at your own risk
// Note - requires Modernizr touch detection build
if (Modernizr.touch && window.innerWidth < 768) {
// mobile user (if a touch screen and the window is smaller than tablet sized)
alert('Mobile Phone');
}
else {
alert('Desktop or Tablet Browser');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment