How to detect mobile devices using jQuery


Hello everyone, yesterday I received a request from the client. He wanted to disable the popup of Newsletter Popup extension when customers visit his website on mobile devices. It gave me a chance to work with jQuery again and finally I came up with a solution which can disable the popup using jQuery. Today, I will show you this tip.

Step 1:

Download detectmobilebrowser.js from

Step 2:

Example Usage

	alert(‘Mobile devices’);
	alert(‘Not mobile devices’);

The example above show you how to detect all mobile devices (mobile phones, small tablets & tablets).
In some cases, if you want to disable on some specific devices, you can view following examples:

Detect iPad

var isiPad = /ipad/i.test(navigator.userAgent.toLowerCase());
if (isiPad){
// Do something

Detect iPhone

var isiPhone = /iphone/i.test(navigator.userAgent.toLowerCase());
if (isiPhone){
  // Do something

Detect iPod

var isiPod = /ipod/i.test(navigator.userAgent.toLowerCase());
if (isiPod){
  // Do something

Detect iDevice

var isiDevice = /ipad|iphone|ipod/i.test(navigator.userAgent.toLowerCase());
if (isiDevice){
  // Do something

Detect Android

var isAndroid = /android/i.test(navigator.userAgent.toLowerCase());
if (isAndroid){
  // Do something

Detect Blackberry

var isBlackBerry = /blackberry/i.test(navigator.userAgent.toLowerCase());
if (isBlackBerry){
  // Do something

Detect WebOS

var isWebOS = /webos/i.test(navigator.userAgent.toLowerCase());
if (isWebOS){
  // Do something

Detect Window Phone

var isWindowsPhone = /windows phone/i.test(navigator.userAgent.toLowerCase());
if (isWindowsPhone){
  // Do something

One thought on “How to detect mobile devices using jQuery”

1 Response to How to detect mobile devices using jQuery