3

我应该使用哪种形式的移动检测,为什么?

<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();
4

1 回答 1

1

你真的在这里看到了几个不同的东西......

当 PHP 脚本在服务器上运行时检测移动浏览器时,html 标签告诉浏览器如何处理某些情况。

每个都有它自己的用途......一般来说,你最终可能会使用两者的组合。

我通常使用一些服务器端脚本检测移动浏览器,然后在检测到移动浏览器时输出 html 标签(如您列出的标签)。

换句话说... 1)用户请求页面 2)PHP(或其他)检测到移动浏览器或标准浏览器 3)如果移动,发送适当的 CSS 文件、标题等。否则,发送一组不同的 CSS 文件和标题。

于 2010-04-21T18:37:09.200 回答