首页 > 攻略 > 软件教程 > js判断移动端跳转代码(替换www为m)方法

js判断移动端跳转代码(替换www为m)方法

2021-10-31 02:43:30编辑:娱乐手游网来源:互联网

js判断移动端跳转代码(替换www为m)方法


if(window!=top){top.location.href=window.location.href;}

var shouji = navigator.userAgent.match(/Android|iPad|iPhone|iPod/i) != null;

var url = window.location.href;

var host = window.location.host;

if(shouji){

if(url.indexOf('//www.') > -1){

var wwwurl = url.replace("//www.","//m.");

location.href= wwwurl;

}

}else{

if(url.indexOf('//m.') > -1){

var wwwurl = url.replace("//m.","//www.");

location.href= wwwurl;

}

}

相关阅读更多 >
推荐新闻
点击加载更多
游戏排行榜更多 >