Skip to content

Instantly share code, notes, and snippets.

@magicmarkker
Created November 12, 2012 19:29
Show Gist options
  • Save magicmarkker/4061366 to your computer and use it in GitHub Desktop.
Save magicmarkker/4061366 to your computer and use it in GitHub Desktop.
isMobile
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i) ? true : false;
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i) ? true : false;
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i) ? true : false;
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment