0

Detect Mobile Devices Using jQuery and javascript

Today i am working on a project where i need the detect mobile device, I have searched and findout the following jQuery code to Detect mobile device. Following jQuery snippets detect various mobile handheld devices such as iPad, iPhone, iPod, iDevice, Andriod, Blackberry, WebOs and Windows Phone.

isMobile Function

Example Code Detect Devices:

Detect iPad

Detect iPod

[code language=”js”]
var isiPod = /ipod/i.test(navigator.userAgent.toLowerCase());
if (isiPod)
{

}
[/code]

Detect iDevice

[code language=”js”]
var isiDevice = /ipad|iphone|ipod/i.test(navigator.userAgent.toLowerCase());

if (isiDevice)
{

}
[/code]

Detect Andriod

[code language=”js”]
var isAndroid = /android/i.test(navigator.userAgent.toLowerCase());

if (isAndroid)
{

}
[/code]

Detect Blackberry

[code language=”js”]
var isBlackBerry = /blackberry/i.test(navigator.userAgent.toLowerCase());

if (isBlackBerry)
{

}
[/code]

Detect WebOs

[code language=”js”]

var isWebOS = /webos/i.test(navigator.userAgent.toLowerCase());

if (isWebOS)
{

}
[/code]

Detect Windows Phone

[code language=”js”]
var isWindowsPhone = /windows phone/i.test(navigator.userAgent.toLowerCase());

if (isWindowsPhone)
{

}
[/code]

Sandeep Kumar

Sandeep kumar is a web developer and a professinal blogger. He works for latest technologies and write articles what he learn. In ICodeHub he share web languages tutorials and other programming tips and tricks. if you need some help or have some suggestion then mail him at sandeep92pal@gmail.com without any hesitation. He believes in learning and sharing.