关于网站页面判断PC端、移动端并跳转的js代码

    关于网站页面判断PC端、移动端并跳转的js代码,添加到头部通用文件即可!

    <script type="text/javascript">
    if(!navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)&&window.location.host.indexOf('m.xx.com')>=0&&window.location.href.indexOf('fromwebmanage')<0){
        window.location = window.location.href.replace("m.xx.com", "www.xx.com");
    }
    </script>

    或者

    <script>
        // PC端 移动端 跳转
        var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
            if (is_mobi) {
                window.location.href = "mobile.html";
            }else{
                // window.location.href="index.html" 
            }
    </script>