-
-
Save tyler-vs/c6a77b936104088c944b3a68932e2355 to your computer and use it in GitHub Desktop.
Detect mobile devices script
This file contains 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
<script type="text/javascript"> | |
var mobile = (/iphone|ipod|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())); | |
if (mobile) { | |
do something; | |
} | |
</script> | |
<script type="text/javascript"> | |
var isAndroid = (/android/i.test(navigator.userAgent.toLowerCase())); | |
if (isAndroid) { | |
// alert("Android"); | |
if (screen.width < 800) { | |
// alert("android portrait"); | |
do something; | |
} else if (screen.height < 800) { | |
do something; | |
//alert("android landscape"); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment