Created
June 18, 2014 23:21
-
-
Save brennanMKE/2eaa6924e3376cd60f96 to your computer and use it in GitHub Desktop.
JavaScript to detect mobile browser and platform.
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
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