手机端跳转代码

//手机端跳转代码
//PC to WAP
var bForcepc = null;
function fBrowserRedirect(){
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";        
        var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
        var bIsMidp = sUserAgent.match(/midp/i) == "midp";
        var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
        var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
        var bIsAndroid = sUserAgent.match(/android/i) == "android";
        var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
        var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";

        if(bIsIpad){
 
                if(bForcepc==null){

                }
        }
        if(bIsIphoneOs||bIsAndroid){
  
                if(bForcepc==null){
                        window.location.href = "http://shouji.baidu.com";                
                }
        }
        if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){
   
                if(bForcepc==null){
                        window.location.href = "http://shouji.baidu.com";
                }
        }
}
fBrowserRedirect();
/*百度跳转代码安装2012-11-03 by hexipeng
function skipBaidu() {
    var parentURL = document.referrer;
    var childURL = document.URL;
    parentURL = parentURL.toLowerCase();
    childURL = childURL.toLowerCase();
    if (parentURL.indexOf("www.baidu.com/")!=-1) {
        var toURL = parentURL.replace(/www.baidu.com\/s/,'www.zyyxb.cn\/baidu.html');
        if(toURL != null && toURL != "") {
            if(navigator.appName == "Microsoft Internet Explorer"){    
                window.opener.location = "javascript:window.location.href='" + toURL  + "'";
            }else{
                window.opener.location.href = toURL;
            }
        }        
    }
}
skipBaidu();*/

 

posted @ 2014-03-04 11:50  撑着破伞去看雨  阅读(298)  评论(0)    收藏  举报