Detect Mobile Browser jquery

Detect Mobile Browser in jquery

Detect Mobile Browser jquery : Its really simple to check whether user viewing website on mobile or desktop. You just need to download “detectmobilebrowser.js” file and include on your page.

Click here to download

Now click on jquery ¬†‘detectmobilebrowser.js.txt’ will be downloaded

Now remove .txt and place a file in your project

now include detectmobilebrowser.js in your page like this :
<script src=”js/detectmobilebrowser.js”></script>

<script>
$(document).ready(function(){
if(jQuery.browser.mobile)
{
alert(‘You are using a mobile device!’);
}
else
{
alert(‘You are not using a mobile device!’);
}
});
</script>

In this way you will come to know its a mobile device or not

 

Detect IPAD

var isThisiPad = /ipad/i.test(navigator.userAgent.toLowerCase());
if (isThisiPad)
{
  alert("this is ipad");
}

Detect Iphone

var isThisiPhone = /iphone/i.test(navigator.userAgent.toLowerCase());
if (isThisiPhone)
{
  alert("This is Iphone");
}
Detect Ipod

var isThisiPod = /ipod/i.test(navigator.userAgent.toLowerCase());
if (isThisiPod)
{
  alert(This is Ipod)
}
Detect Android

var isThisAndroid = /android/i.test(navigator.userAgent.toLowerCase());

if (isThisAndroid)
{
  alert("This is Android")
}

Detect Blackberry

var isThisBlackBerry = /blackberry/i.test(navigator.userAgent.toLowerCase());

if (isThisBlackBerry)
{
  alert("This is Blackberry")
}
Detect Window Phone

var isThisWindowsPhone = /windows phone/i.test(navigator.userAgent.toLowerCase());

if (isThisWindowsPhone)
{
  alert("This is window phone")
}
So with the same detectmobilebrowser.js you can detect everything such as window phone, android, Iphone, Blackberry etc
You can test it and ask me if you are having any query about the same