Skip to content

Instantly share code, notes, and snippets.

@marcolago
Last active August 29, 2015 14:00
Show Gist options
  • Save marcolago/11394843 to your computer and use it in GitHub Desktop.
Save marcolago/11394843 to your computer and use it in GitHub Desktop.
isMobile Check
var isMobile = (function() {
var ret = {};
ret.Android = navigator.userAgent.match(/Android/i) !== null;
ret.BlackBerry = navigator.userAgent.match(/BlackBerry/i) !== null;
ret.iPhone = navigator.userAgent.match(/iPhone|iPod/i) !== null;
ret.iPad = navigator.userAgent.match(/iPad/i) !== null;
ret.iOS = (ret.iPhone || ret.iPad);
ret.Opera = navigator.userAgent.match(/Opera Mini/i) !== null;
ret.Windows = navigator.userAgent.match(/IEMobile/i) !== null;
ret.any = (ret.Android || ret.BlackBerry || ret.iOS || ret.Opera || ret.Windows);
return ret;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment