可以通过javascript或HTTP标头检测*类型的移动设备*? [英] Possible to detect the *type of mobile device* via javascript or HTTP Headers?

查看:127
本文介绍了可以通过javascript或HTTP标头检测*类型的移动设备*?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了客户的请求,要求自动检测移动设备的类型(不是浏览器,类型。例如:Moto Q,Blackjack II等)并自动从下拉列表中选择设备支持的设备列表。

I've got a request from a customer to automatically detect the type of mobile device (not the browser, the type. ex: Moto Q, Blackjack II, etc.) and automatically select the device from a drop down with a list of supported devices.

到目前为止,我发现HTTP标头(由移动IE提交)包含诸如

So far I've found that the HTTP Headers (submitted by mobile IE) contain information such as


  • 分辨率

  • UA-CPU(我见过WM 2003的ARM和WM5的x86)

  • 用户代理(基本上只是说Windows CE)

我现在唯一能想到的可能就是使用组合分辨率/ cpu并做出最佳猜测

The only thing I can think of right now is possibly using a combination of the resolution/cpu and making a "best guess"

有什么想法吗?

推荐答案

客户对支持的具体含义是什么。当然,这意味着有问题的手机支持Web应用程序及其内部功能 - 忘记设备检测并且只关注检测应用程序正常运行所需的那些功能不是更好吗?例如,如果我的移动网站需要Ajax才能工作,那么我可以做一些简单的对象检测,而不是列出所有被称为支持Ajax的设备。

What exactly does the customer mean by "supported". Surely it means that the phone in question supports the web application and it's inner functionality - wouldn't it be better then to forget device detection and simply focus on detecting those capabilities required for the app to function properly? For example, if my mobile website requires Ajax to work then instead of listing all the devices which are said to "support Ajax" I could do some simple object detection to find out for myself.

设备检测,就像浏览器检测不可靠一样。是的,这是可能的,但我不会推荐它......在我完成的项目中,我们使用User Agent字符串来检测各种设备。 indexOf javaScript方法派上用场了! :)

Device detection, just like browser detection is unreliable. Yes, it's possible but I wouldn't recomend it... on a project I've done we used the User Agent string to detect various devices. The indexOf javaScript method came in handy! :)

这篇关于可以通过javascript或HTTP标头检测*类型的移动设备*?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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