Skip to content

Instantly share code, notes, and snippets.

@miketaylr
Created November 13, 2013 18:30
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 miketaylr/7453940 to your computer and use it in GitHub Desktop.
Save miketaylr/7453940 to your computer and use it in GitHub Desktop.
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
FxOS: function(){
return navigator.userAgent.match(/mobi/i)
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
SymbianOS: function() {
return navigator.userAgent.match(/SymbianOS/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.FxOS() ||isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment