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>

作者最新文章
C# 实现字符串文本换行的方法,文本如何换行
C# 如何循环读取文件每一行文本内容
C# DateTime AddMonths 的错误用法导致跳过日期
C# 全角转换半角,半角转换为全角
C# Word 转换 PDF 文件,如何转换 PDF