我如何检测用户是否正在从移动网络浏览器浏览我的网站,以便我可以自动检测和显示我的网站的适当版本?


当前回答

有一个全新的解决方案使用Zend框架。从Zend_HTTP_UserAgent的链接开始:

http://framework.zend.com/manual/en/zend.http.html

其他回答

以下是我如何在JavaScript中做到这一点:

function isMobile() {
  var index = navigator.appVersion.indexOf("Mobile");
  return (index > -1);
}

在www.tablemaker.net/test/mobile.html上可以看到一个例子,它把手机上的字体放大了三倍。

在检测移动浏览器上有开源脚本,可以在Apache、ASP、ColdFusion、JavaScript和PHP中实现这一点。

有一个全新的解决方案使用Zend框架。从Zend_HTTP_UserAgent的链接开始:

http://framework.zend.com/manual/en/zend.http.html

移动设备浏览器文件是检测移动(和其他)ASP浏览器的好方法。NET项目:http://mdbf.codeplex.com/

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.Browser.IsMobileDevice == true)
    {
        Response.Redirect("Mobile//home.aspx");
    }
}

这个例子在asp.net中工作