Skip to content

Instantly share code, notes, and snippets.

@beatak
Created June 13, 2012 01:36
Show Gist options
  • Save beatak/2921243 to your computer and use it in GitHub Desktop.
Save beatak/2921243 to your computer and use it in GitHub Desktop.
ghetto mobile checking
(function () {
var _mobile;
window.isMobile = function () {
if (!_mobile) {
var ua = navigator.userAgent;
_mobile = {
a: ua.match(/Android/i) ? true : false,
bb: ua.match(/BlackBerry/i) ? true : false,
ios: ua.match(/iPhone|iPad|iPod/i) ? true : false,
win: ua.match(/IEMobile/i) ? true : false
};
_mobile.any = _mobile.a || _mobile.bb || _mobile.ios || _mobile.win;
};
return _mobile.any;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment