Skip to content

Instantly share code, notes, and snippets.

@jrran90
Created November 27, 2019 12:58
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 jrran90/92fef792f2f99707a3b776acd5880691 to your computer and use it in GitHub Desktop.
Save jrran90/92fef792f2f99707a3b776acd5880691 to your computer and use it in GitHub Desktop.
Detect user agent

This will detect if it's using mobile or not

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)) { 
  // true
} else { 
  // false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment