Created
June 13, 2012 01:36
-
-
Save beatak/2921243 to your computer and use it in GitHub Desktop.
ghetto mobile checking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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