目标:想在手机端判断是不是百度来源,根据百度来源在做策略跳转
判断条件
1.判断是手机、并且是手机百度网址来源。
2.判断是手机百度APP来源。
JS判断代码
-
//获取来源
-
var where = document.referrer,
-
//ua信息
-
sUserAgent = navigator.userAgent.toLowerCase();
-
//判断是百度来源并且是手机 或者 百度手机APP
-
if ((where.indexOf(".baidu.com/")> -1 && browserRedirect() ) || (where=='' && sUserAgent.indexOf('baiduboxapp/') >-1)){
-
location.href = "跳转的链接";
-
}
-
-
//判断手机
-
function browserRedirect() {
-
-
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";
-
return (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) ;
-
-
}
发表评论