检测的Andr​​oid设备是否是一个电话或使用JavaScript平板 [英] Detecting whether Android device is a phone or a tablet with javascript

查看:115
本文介绍了检测的Andr​​oid设备是否是一个电话或使用JavaScript平板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚建立了一个移动网站,并希望从我们的主网站重定向流量,如果用户在浏览手机。

I have just built a mobile site and want to redirect the traffic from our main site if the user is browsing through a mobile phone.

目前我使用JavaScript来拿起浏览器的用户代理和使用,以确定如果设备是手机。

Currently I am using javascript to pick up the browser useragent and using that to identify if the device is a mobile phone.

这个问题我已经是Android设备,因为我无法找到一个显着特点为Android useragents决定设备是手机还是平板电脑,如果用户在平板电脑上我还是想向他们展示了完整的网站。

The issue I have is with Android devices as I cannot find a distinguishing feature for Android useragents to decide whether the device is a phone or a tablet, If the user is on a tablet I still want to show them the full site.

有谁知道一个解决方案吗?

Does anyone know of a solution for this?

推荐答案

您应该通过读取用户代理可能使用此sugestion由谷歌进行。如果UA具有字移动它是一个电话,如果它不是一个药片

You should probably use this sugestion made by google by reading the user agent. If the UA has the word mobile it's a phone, if it doesn't it's a tablet

<一个href="http://googlewebmastercentral.blogspot.com/2011/03/mo-better-to-also-detect-mobile-user.html">http://googlewebmastercentral.blogspot.com/2011/03/mo-better-to-also-detect-mobile-user.html

这篇关于检测的Andr​​oid设备是否是一个电话或使用JavaScript平板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆