用js实现判断当前网址的来路如果不是指定的来路就跳转到指定页面


复制代码 代码如下:

<script type="text/javascript">
if(self!=top){top.location=self.location;}
var ref=document.referrer;
var domains=new Array("phpstudy.net/","phpstudy.cn/","phpstudy.com.cn/");
var refpass=false;
for(i=0;i<=domains.length;i++){if(ref.indexOf(domains[i])>0){refpass=true;break;}}
if(ref==""){refpass=true}
if(!refpass){window.location.href='http://www.phpstudy.net';}
</script>
复制代码 代码如下:
<script type="text/javascript">
if(self!=top){top.location=self.location;}
var ref=document.referrer;
var domains=new Array("phpstudy.net/","phpstudy.cn/","phpstudy.com.cn/");
var refpass=false;
for(i=0;i<=domains.length;i++){if(ref.indexOf(domains[i])>0){refpass=true;break;}}
if(ref==""){refpass=true}
if(!refpass){window.location.href='http://www.phpstudy.net';}
</script>

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3