【问题标题】:Simple way to check whether user is mobile device?检查用户是否是移动设备的简单方法?
【发布时间】:2011-04-10 07:31:31
【问题描述】:

我希望在我的主页上为主要移动操作系统(至少是 Android、Nokia/Symbian、Windows、iOS 和 Blackberry 操作系统)的用户创建一个简单的重定向。

目前我可以在 iPhone / iPod 上使用它(见下文),但我想知道 JavaScript 中是否有一种简单的方法来检查所有内容。 (而不是仅仅写出一大堆移动用户代理)。

也许是检测屏幕大小的东西?

// Current Code
<script type="text/javascript">
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    if (document.cookie.indexOf("iphone_redirect=false") == -1) {
        window.location = "http://m.domain.co.nz";
    }
}
</script>

【问题讨论】:

标签: javascript html


【解决方案1】:

这在服务器上正确完成,而不是在客户端上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-06
    • 1970-01-01
    • 2016-09-27
    • 2018-02-09
    • 2016-09-02
    • 2022-10-14
    相关资源
    最近更新 更多