转载[Mobile Web]Web中如何分辨移动设备?(iPad、iPhone、Android)

已验证过javascript方法可以使用

var deviceAgent = navigator.userAgent.toLowerCase();  
02. var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);  
03. if(agentID.indexOf("iphone")>=0){  
04.  alert("iphone");  
05. }  
06. if(agentID.indexOf("ipod")>=0){  
07.  alert("ipod");  
08. }  
09. if(agentID.indexOf("ipad")>=0){  
10.  alert("ipad");  
11. }  
12. if(agentID.indexOf("android")>=0){  
13.  alert("android");  
14. }  

这两种方法测试下来,一般情况下可以满足需要,遇到像UC浏览器这些第三方浏览器,可能就不准了!

来源:http://blog.csdn.net/feng88724/article/details/7312827

原文地址:https://www.cnblogs.com/blog4xy/p/4119420.html