Skip to content

Instantly share code, notes, and snippets.

@endigo9740
Created March 7, 2012 18:18
Show Gist options
  • Save endigo9740/1994877 to your computer and use it in GitHub Desktop.
Save endigo9740/1994877 to your computer and use it in GitHub Desktop.
Javascript: Mobile User Agent
<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