修正js跳转
阅读原文时间:2023年07月10日阅读:2

var urls = new Array();
urls["pc"] = "./hp"; //pc
urls["sj"] = "./hs"; //shouji
urls["wx"] = "./hw"; //weixin
tiao(urls);
function tiao(urls){
var pc = IsPC();
var weixin = is_weixin();
var shouji = !(pc||weixin);
if(pc){
window.location = urls['pc'];
}else if(weixin){
window.location = urls['wx'];
}else{
window.location = urls['sj'];
}
}
function is_weixin() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
// $("#rs").text("微信浏览器");
} else {
return false;
// $("#rs").text("不是微信浏览器");
}
}
function IsPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}