Skip to content

Instantly share code, notes, and snippets.

@Ugarz
Created December 10, 2015 13:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ugarz/8fc01005b87b54ef1948 to your computer and use it in GitHub Desktop.
Save Ugarz/8fc01005b87b54ef1948 to your computer and use it in GitHub Desktop.
Check if your device if mobile or tablet in Javascript
window.mobileAndTabletcheck = function() {
var check = false;
(function(a) {
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) ||
if (window.mobileAndTabletcheck == true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment