-
-
Save jonlunsford/3515086 to your computer and use it in GitHub Desktop.
How to detect mobile devices on your site :)
This file contains 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 = function() { | |
var mobile = (/iphone|ipad|ipod|iemobile|android|meego|nokia|blackberry|mini|symbian|windows\sce|palm/gi.test(navigator.userAgent.toLowerCase())); | |
if (mobile) return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regex was updated to include a couple more UA's and a global flag was added to better match Nokia devices for my purposes. Credit to @kamenov for a great little Gist.