打开链接自动匹配跳转手机端链接还是pc端链接
作者:
孙静静 | 来源:发表于
2019-08-21 10:54 被阅读2次// 判断机型
function IsPC() {
// 声明了浏览器用于 HTTP 请求的用户代理头的值
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;
};
window.onload=function(){
var isPC=IsPC();
if(isPC){
//自动跳到pc端链接
window.location.href="http://xxxx/pm/2019/znyy/index.html";
}else{
//自动跳到移动端端链接
window.location.href="http://xxxx/pm/2019/znyy/index_phone.html";
}
};
本文标题:打开链接自动匹配跳转手机端链接还是pc端链接
本文链接:https://www.haomeiwen.com/subject/ckcbsctx.html
网友评论