Detect Mobile Devices

by Zuhaib Siddiqui

HTML

<h1>Find Mobile Operation System & Check Mobile Touch Here:</h1>
<p>http://stackoverflow.com/questions/6262584/how-to-determine-if-the-client-is-a-touch-device/15481500#15481500</p>

http://jqtjs.com/

JavaScript

var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function() {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};


if( isMobile.any() ) alert('Mobile');

if( isMobile.iOS() ) alert('iOS');