2011-04-10 66 views
1

我期待在我的主页上为主要移动操作系统(至少Android,诺基亚/ Symbian,Windows,iOS和Blackberry OS)的用户创建一个简单的重定向。简单的方法来检查用户是否是移动设备?

目前我有它的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> 
+1

[自动检测手机浏览器(通过用户代理?)]可能的重复(http://stackoverflow.com/questions/1005153/auto-detect-mobile-browser-via-user-agent) – 2011-04-10 07:38:11

+1

我是不写这个答案,但你可能会发现这个有用的:http://detectmobilebrowser.com/ – Nobita 2011-04-10 07:41:41

回答

1

这适当地在服务器上完成,而不是在客户端上。

相关问题