Created
March 19, 2012 19:49
-
-
Save bspingarn/2125777 to your computer and use it in GitHub Desktop.
Javascript - mobile phone detection excluding tablets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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