【手机端判断】PC_to_M自写

var current_url = window.location.href;
var replace_url = [
    [‘笔试简章‘,‘http://beijing.ysedu.com/zt/bjtk.html‘,‘http://www.ysedu.com/zt/mbs.html‘],
    [‘面试简章‘,‘http://beijing.ysedu.com/zt/bjpms.html‘,‘http://www.ysedu.com/zt/m2017ms.html‘],
    [‘教招简章‘,‘http://beijing.ysedu.com/zt/zhaojiao.html‘,‘http://www.ysedu.com/zt/m2017zk.html‘],
    [‘普通话简章‘,‘http://beijing.ysedu.com/zt/bjpth.html‘,‘http://www.ysedu.com/zt/m2017pth.html‘],
];
var jump_url = "";
for(var i=0;i<replace_url.length;i++){
    if(current_url.match(replace_url[i][1])){
        jump_url = replace_url[i][2];
    }
}
function browserRedirect() {
    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 || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
        return true;
    }
        return false;
}
if(browserRedirect() && jump_url){
    window.location.href = jump_url;
}

用于PC页面和手机页面判断跳转

【手机端判断】PC_to_M自写

上一篇:js中Array数组基本方法


下一篇:ASP.NET Core-自定义Jwt token验证(ISecurityTokenValidator)