Skip to content

Instantly share code, notes, and snippets.

@marioluevanos
Created July 23, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marioluevanos/f89655d79d97183e8c82c5306859b360 to your computer and use it in GitHub Desktop.
Save marioluevanos/f89655d79d97183e8c82c5306859b360 to your computer and use it in GitHub Desktop.
If a mobile device, return boolean
const ifMobile = () => {
if( navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPod/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/IEMobile/i) ||
navigator.userAgent.match(/Opera Mini/i)
) {
return navigator.userAgent
}
else return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment