HTTP:确定设备访问站点是否可移动的最可靠方法 [英] HTTP: Most reliable way to determine if device accessing site is mobile

查看:87
本文介绍了HTTP:确定设备访问站点是否可移动的最可靠方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定访问站点的设备是否是移动设备的最可靠方法是什么?还应该有一种方法来区分设备是平板电脑还是智能手机.平板电脑可以是10英寸,因此能够显示正常的网页,而智能手机则不能,我想提供智能手机专用的内容.我想我实际上应该检查的是屏幕分辨率,但是我找不到一种可靠的方法.屏幕分辨率应以像素为单位,而不是每英寸像素.因此,我的网站会将320x480或480x600和600x800视为移动设备.但是1024x768的图片可能应该被认为是台式机.

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.

推荐答案

所以我们开始:

http://detectmobilebrowsers.com/-您可以使用此处的工具来检测访问者是否在移动设备上.但是...

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

http://modernizr.com/docs/#s2 -在这里您可以检测到特征.与功能/移动设备/台式机相比,通过功能进行一些后备的方式要好一些

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/-在这里,您已内置媒体查询,可用于检测屏幕尺寸.您可以在此处检查运行情况,例如: https://github.com /twitter/bootstrap/blob/master/less/response.less

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:确定设备访问站点是否可移动的最可靠方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆