3
我应该使用哪种形式的移动检测,为什么?移动检测 - Meta标签和最大设备宽度与PHP用户代理?
<meta name="viewport" content="width=320,initial-scale=1,maximum-scale=1.0,user-scalable=no" />
<link media="only screen and (max-device-width: 480px) and (min-device-width: 320px)" href="css/mobile.css" type= "text/css" rel="stylesheet">
<link media="handheld, only screen and (max-device-width: 319px)" href="css/mobile_simple.css" type="text/css" rel="stylesheet" />
或者
include('mobile_device_detect.php');
$mobile = mobile_device_detect();
第一个示例没有检测到移动设备,它只是根据屏幕大小加载不同的css文件。如果您只有一个版本的网站,并且想要在小屏幕上以不同的方式进行设计,那么效果会很好。如果您想要将移动用户重定向到您网站的其他版本,则需要检测移动设备,如第二个示例所示。 – 2011-12-07 02:06:00