zoukankan      html  css  js  c++  java
  • 手机平板等移动端适配跳转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>
    function uaredirect(f){try{if(document.getElementById("bdmark")!=null){return}var b=false;if(arguments[1]){var e=window.location.host;var a=window.location.href;if(isSubdomain(arguments[1],e)==1){f=f+"/#m/"+a;b=true}else{if(isSubdomain(arguments[1],e)==2){f=f+"/#m/"+a;b=true}else{f=a;b=false}}}else{b=true}if(b){var c=window.location.hash;if(!c.match("fromapp")){if((navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i))){location.replace(f)}}}}catch(d){}}function isSubdomain(c,d){this.getdomain=function(f){var e=f.indexOf("://");if(e>0){var h=f.substr(e+3)}else{var h=f}var g=/^www./;if(g.test(h)){h=h.substr(4)}return h};if(c==d){return 1}else{var c=this.getdomain(c);var b=this.getdomain(d);if(c==b){return 1}else{c=c.replace(".","\.");var a=new RegExp("\."+c+"$");if(b.match(a)){return 2}else{return 0}}}};
    <script type="text/javascript">uaredirect("你的手机版网址");</script>
  • 相关阅读:
    风火轮 –动画效果:擦除、形状、轮子、随机线条、翻转远近、缩放、旋转、弹跳效果
    风火轮 –动画效果:浮入与劈裂
    风火轮 – 飞入动画效果
    风火轮 1
    CB XE6初体验
    在CB2010中调用ffmpeg(5)
    在CB2010中调用ffmpeg(4)
    在CB2010中调用ffmpeg(3)
    在CB2010中调用ffmpeg(2)
    0-99累加
  • 原文地址:https://www.cnblogs.com/dudumao/p/3812326.html
Copyright © 2011-2022 走看看