Reputation: 365
By this article http://www.abeautifulsite.net/blog/2011/11/detecting-mobile-devices-with-javascript/ I was successfully able to detect Iphone,Ipod,Ipad,Android device. How can I detect Blackberry mobile/playbook and Windows phones?
Upvotes: 0
Views: 819
Reputation: 1361
You can detect BlackBerry devices by using:
navigator.userAgent.match(/BlackBerry|BB|PlayBook/i);
You can detect Windows devices by using:
navigator.userAgent.match(/IEMobile|Windows Phone/i);
However, if you are just trying to detect if the user is on ANY mobile device, I recommend using this code:
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)) {
// Do something for mobile users.
} else {
// Do something for non-mobile users.
}
Upvotes: 0