简体   繁体   中英

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. 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.

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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