HTTP: Most reliable way to determine if device acc

2019-08-12 06:43发布

问题:

What is the most reliable way to determine whether the device accessing a site is a mobile device? There should also be a way to distinguish whether the device is a tablet or smartphone. A tablet can be 10 inches and therefore is capable of displaying a normal web page whereas a smartphone cannot and I want to deliver content specific to smartphones. I guess really what I should be checking is the screen resolution but I wasn't able to find a reliable way of doing that. The screen resolution should be in pixels and not pixels per inch. So 320x480 or 480x600 and 600x800 would be considered by my site to be mobile. But something with 1024x768 probably should be considered a desktop.

回答1:

so here we go:

http://detectmobilebrowsers.com/ - here you have tool for detecting if your visitor is on mobile device. But ...

http://modernizr.com/docs/#s2 - here you have tool to detect features. It's way better to make some fallback by features than by mobile/desktop

http://www.w3.org/TR/css3-mediaqueries/ - here you have built in media queries that you can use to detect screen size. You can check that in action for example here: https://github.com/twitter/bootstrap/blob/master/less/responsive.less



标签: http mobile