Created
March 7, 2012 18:18
-
-
Save endigo9740/1994877 to your computer and use it in GitHub Desktop.
Javascript: Mobile User Agent
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> | |
var ua = navigator.userAgent; | |
var checker = { | |
ios: ua.match(/(iPhone|iPod|iPad)/), | |
blackberry: ua.match(/BlackBerry/), | |
android: ua.match(/Android/), | |
windowsphone: ua.match(/Windows Phone/) | |
}; | |
$(document).ready(function() { | |
if (checker.ios) { /* iOS Code */ } | |
else if (checker.blackberry) { /* BlackBerry Code */ } | |
else if (checker.android) { /* Android Code */ } | |
else if (checker.windowsphone) { /* Windows Phone Code */ } | |
else { /* Everything Else */ } | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment