使用JavaScript函数来检测移动设备
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
if(isMobile.any()) {
alert("This is a Mobile Device");
}
另一个JavaScript伎俩来检测移动设备
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
// tasks to do if it is a Mobile Device
alert("Mobile Detected");
}
Detect Mobile Browser有脚本来检测手机大集合设备。您可以获得针对Apache,ASP,ASP.NET,ColdFusion,C#,IIS,JSP,JavaScript,jQuery,Lasso,nginx,node.js,PHP,Perl,Python,Rails等移动设备检测脚本
这不是Android的编程。在网页部分询问。 – Wildcopper
可能的重复[在jQuery中检测移动设备的最佳方法是什么?](http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-设备在jquery) – Manu