Skip to content

Instantly share code, notes, and snippets.

@tsbits
Last active August 29, 2015 14:10
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 tsbits/f847deba6563d466e354 to your computer and use it in GitHub Desktop.
Save tsbits/f847deba6563d466e354 to your computer and use it in GitHub Desktop.
Mobile OS detection
//From http://stackoverflow.com/questions/12606245/detect-if-browser-is-running-on-an-android-or-ios-device
var isMobile = {
Android: function() {
return /Android/i.test(navigator.userAgent);
},
BlackBerry: function() {
return /BlackBerry/i.test(navigator.userAgent);
},
iOS: function() {
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
},
Windows: function() {
return /IEMobile/i.test(navigator.userAgent);
},
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