您的位置
主页 > 网站技术 > 语言编程 > » 正文

手机平板等移动端适配跳转URL的js代码

来源: 站长圈 点击:

代码如下:

<script type="text/javascript">

if(/AppleWebKit.*mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){

    if(window.location.href.indexOf("?mobile")<0){

        try{

            if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){

                window.location.href="手机页面";

            }else if(/iPad/i.test(navigator.userAgent)){

                window.location.href="平板页面";

            }else{

                window.location.href="其他移动端页面"

            }

        }catch(e){}

    }

}

</script>




首页  - 关于站长圈  - 广告服务  - 联系我们  - 关于站长圈  - 网站地图  - 版权声明