简体   繁体   English

是否可以使用javascript或ASP.Net检测移动设备模型

[英]Is it possible to detect the mobile device model using javascript or ASP.Net

I have a website that will display mobile accessories and I'm thinking that it would be nice if the website was able to detect the user's mobile device that's requesting the page so it would display products for this specific model. 我有一个网站,上面会显示移动配件,我想如果该网站能够检测到请求该页面的用户移动设备,从而能够显示该特定型号的产品,那将是很好的选择。

Any way to achieve this in javascript, jQuery or .Net is appreciated. 任何用javascript,jQuery或.Net实现此目的的方法都值得赞赏。 Thanks. 谢谢。

Detecting the client reliably is not easy, but the best you can do is to look in the user agent string supplied by the client. 要可靠地检测客户端并不容易,但是最好的办法是查看客户端提供的用户代理字符串。

In ASP.NET you can access it through Request.UserAgent property. 在ASP.NET中,可以通过Request.UserAgent属性访问它。

You will have to find the exact user agents that you want to look for to identify phone models. 您将必须找到要查找的确切用户代理才能识别手机型号。 This is for example my old Xperia Mini Pro: 例如,这是我的旧版Xperia Mini Pro:

Mozilla/5.0 (Linux; U; Android 2.3.4; sv-se; SonyEricssonSK17i Build/4.0.2.A.0.58) AppleWebKit/533.1 (KHTML, like Gecko) Vers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM