Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonlunsford/3515086 to your computer and use it in GitHub Desktop.
Save jonlunsford/3515086 to your computer and use it in GitHub Desktop.
How to detect mobile devices on your site :)
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;
}
@jonlunsford
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment