Created
March 7, 2012 19:00
-
-
Save jonatasnona/1995124 to your computer and use it in GitHub Desktop.
Javascript: UserAgent
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
<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> |
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
<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