js 判断是否为手机端、移动端访问

js 判断是否为手机端、移动端访问
<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <script type="text/javascript" src="/js/jquery-1.4.1.min.js"></script>
    <script type="text/javascript">
        (function () {
            var mobileAgents = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "wap", "skyfire", 'mobile', "symbian", "windows ce");
            var browser = navigator.userAgent.toLowerCase();
            for (var i = 0; i < mobileAgents.length; i++) {
                if (browser.indexOf(mobileAgents[i]) != -1) {
                    //alert(mobileAgents[i]); 
                    location.href = 'http://m.abc.com';
                    break;
                }
            } 
        })();
    </script>
    <title></title>
</head>
<body>

</body>
</html>

热门推荐