Skip to content

Instantly share code, notes, and snippets.

@stormwarning
Last active August 29, 2015 13:57
Show Gist options
  • Save stormwarning/9413913 to your computer and use it in GitHub Desktop.
Save stormwarning/9413913 to your computer and use it in GitHub Desktop.
Quick & dirty browser sniff to detect mobile devices.
/**
* Quick & dirty browser sniff to detect mobile devices.
*/
var isMobile = false;
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)
) {
isMobile = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment