Android:智能手机或平板电脑

时间:2012-12-23 15:57:52

标签: javascript android webserver browser

从Android设备接收网络请求时,有没有办法知道它是来自智能手机还是平板电脑?如果必须预先应用任何Javascript调整 - 也不错。

1 个答案:

答案 0 :(得分:0)

基本上通过检查useragent

this does not work in all cases (search for Mobile),但几乎所有情况都应该在以后的版本中更好地工作。上面唯一的例外似乎是在平板电脑上使用的不常见的浏览器。

JS

var appv= navigator.appVersion.toLowerCase();
if(appv.search("android") > -1 && !(appv.search("mobile"))){
  //is android tablet
}else if (appv.search("android") > -1){
  //is android phone
}