根据访问的不同页面跳转不同的地址

var r=location.href; 
//跳转到不同的地址,可以写多几个。
if(r.indexOf("这里写网站地址")>-1 ){
  location.href="https://www.baidu.com/";
}
//如需要多个url跳转到同一个地址
if(r.indexOf("网站地址1")>-1 or r.indexOf("网站地址2")>-1 or r.indexOf("网站地址3")>-1){
  location.href="https://www.baidu.com/";
}


//在当前窗口打开,就是跳转
window.location.href="http://www.baidu.com";
//在新窗口打开,就是弹窗
window.open("http://www.baidu.com");
//返回上一页
window.history.back(-1);
//跳转链接
self.location.href="baidu.com"

原文地址:https://www.cnblogs.com/gzpu/p/12350337.html