可以通过javascript或HTTP标头检测*类型的移动设备*?

时间:2021-03-09 21:22:55

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.

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

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

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

  • Resolution
  • UA-CPU (i've seen ARM from WM 2003 and x86 from WM5)
  • UA-CPU(我见过WM 2003的ARM和WM5的x86)

  • User Agent (which basically just says Windows CE)
  • 用户代理(基本上只是说Windows CE)

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

我现在唯一能想到的可能是使用分辨率/ cpu的组合并进行“最佳猜测”

Any thoughts?

3 个解决方案

#1


2  

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.

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

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! :)

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

#2


4  

You may want to have a look at WURFL, here: http://wurfl.sourceforge.net/.

您可以在这里查看WURFL:http://wurfl.sourceforge.net/。

From the site:

从网站:

So... What is WURFL? The WURFL is an XML configuration file which contains information about capabilities and features of many mobile devices.

那么......什么是WURFL? WURFL是一个XML配置文件,其中包含有关许多移动设备的功能和功能的信息。

The main scope of the file is to collect as much information as we can about all the existing mobile devices that access WAP pages so that developers will be able to build better applications and better services for the users.

该文件的主要范围是尽可能多地收集有关访问WAP页面的所有现有移动设备的信息,以便开发人员能够为用户构建更好的应用程序和更好的服务。

#3


0  

Another fast and easy solution is Apache Mobile Filter: http://www.apachemobilefilter.org

另一个快速简便的解决方案是Apache Mobile Filter:http://www.apachemobilefilter.org

#1


2  

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.

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

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! :)

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

#2


4  

You may want to have a look at WURFL, here: http://wurfl.sourceforge.net/.

您可以在这里查看WURFL:http://wurfl.sourceforge.net/。

From the site:

从网站:

So... What is WURFL? The WURFL is an XML configuration file which contains information about capabilities and features of many mobile devices.

那么......什么是WURFL? WURFL是一个XML配置文件,其中包含有关许多移动设备的功能和功能的信息。

The main scope of the file is to collect as much information as we can about all the existing mobile devices that access WAP pages so that developers will be able to build better applications and better services for the users.

该文件的主要范围是尽可能多地收集有关访问WAP页面的所有现有移动设备的信息,以便开发人员能够为用户构建更好的应用程序和更好的服务。

#3


0  

Another fast and easy solution is Apache Mobile Filter: http://www.apachemobilefilter.org

另一个快速简便的解决方案是Apache Mobile Filter:http://www.apachemobilefilter.org