Skip to content

Instantly share code, notes, and snippets.

@zogreptile
Created September 26, 2017 04:00
Show Gist options
  • Save zogreptile/2538436d58fe7cbe95b50a11018cf5a4 to your computer and use it in GitHub Desktop.
Save zogreptile/2538436d58fe7cbe95b50a11018cf5a4 to your computer and use it in GitHub Desktop.
Check if user agent is mobile
function isMobile() {
if (
navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPod/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/Windows Phone/i)
) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment