根据浏览器跳转到手机网站还是电脑网站

<script type="text/javascript">
    var browser = {
        versions: function() {
            var u = navigator.userAgent, app = navigator.appVersion;
            return {
//移动终端浏览器版本信息                                                              
                mobile: (!!u.match(/AppleWebKit.*Mobile/) || !!u.match(/Windows Phone/) || !!u.match(/Android/) || !!u.match(/MQQBrowser/)) && !u.match(/iPad/) //是否为移动终端                                 
            };
        }()
    };
    if (browser.versions.mobile) {
        window.location.href = "http://m.baidu.com";
    } else {
        window.location.href = "http://www.baidu.com";
    }
</script>

 

posted @ 2014-07-11 11:57  学亮  阅读(311)  评论(0编辑  收藏  举报