Skip to content

Instantly share code, notes, and snippets.

@LaurentFough
Created March 9, 2016 09:03
Show Gist options
  • Save LaurentFough/bfc31a58cc184a2dc0a6 to your computer and use it in GitHub Desktop.
Save LaurentFough/bfc31a58cc184a2dc0a6 to your computer and use it in GitHub Desktop.
<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