HTTP: Most reliable way to determine if device accessing site is mobile

邮差的信 提交于 2019-12-11 06:38:02

问题


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



来源:https://stackoverflow.com/questions/11650870/http-most-reliable-way-to-determine-if-device-accessing-site-is-mobile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!