Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Posts Tagged ‘detect mobile’

Using Jquery detect mobile

Posted by Viral Sarvaiya on October 22, 2013


Toay i get good script of jQuery that detect mobile.

It require to Jquery file – http://code.jquery.com/jquery-1.8.3.js

Here code is.

$(document).ready(function () {
  var isMobile = {
    Android: function () {
      return navigator.userAgent.match(/Android/i) ? true : false;
    },
    BlackBerry: function () {
      return navigator.userAgent.match(/BlackBerry/i) ? true : false;
    },
    iOS: function () {
      eturn navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
    },
    Windows: function () {
      return navigator.userAgent.match(/IEMobile/i) ? true : false;
    },
    any: function () {
      return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
    }
  };
  alert(isMobile.any())
});

Hope it helps you.

Thanks.

Posted in Javascript, Jquery | Tagged: , , , , | Leave a Comment »

 
%d bloggers like this: