Last active
April 2, 2024 15:13
-
-
Save burners77/5160231 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