[英]How to detect Blackberry mobile/playbook and Windows phone by Javascript?
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. 通过本文http://www.abeautifulsite.net/blog/2011/11/detecting-mobile-devices-with-javascript/我成功地能够检测到Iphone,Ipod,Ipad,Android设备。 How can I detect Blackberry mobile/playbook and Windows phones?
如何检测黑莓手机/剧本和Windows手机?
You can detect BlackBerry devices by using: 您可以使用以下方法检测BlackBerry设备:
navigator.userAgent.match(/BlackBerry|BB|PlayBook/i);
You can detect Windows devices by using: 您可以使用以下方法检测Windows设备:
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.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.