Javascript document.referrer正在循环播放

时间:2016-02-09 15:54:20

标签: javascript redirect indexof intranet referrer

我是一名新程序员,所以我愿意学习更多标准的编程方法。

目前: 我在重定向来自某些网站的用户时遇到了问题。

这是我正在处理的内联网网站。



 //Redirect to the correct FAQ page
var url = document.referrer;
 //If both are not in the http referrer do nothing
if (url.toLowerCase().indexOf('srs') === -1 && url.toLowerCase().indexOf('pts2') === -1) {
  //PTS2 and SRS are not present in http referrer
}
 //If pts2 is not detected SRS must of been redirect to srs_faq
 else if (url.toLowerCase().indexOf('pts2') === -1) {
  //SRS was detected, redirect to SRS's FAQ
  window.location.replace("http://abc/qa_faqs/srs_faq.html");
}
 //Do nothing for PTS2 referrer
 else if (url.toLowerCase().indexOf('srs') === -1) {
  //PTS2 is present in http referrer	
} else {
  //If this code runs, the gods are cruel.
  alert(url);
}




我做错了什么?

我是新手,并没有在我自己的帖子中解释我的解决方案。所以这就是我想出来解决我所引用的引用问题的黑客攻击。

我将代码编辑到每个单独的页面以适应我想要的重定向。



//Gives me the referrer
var urlR = document.referrer;

//If it did not come from any known referrer, Do Nothing
if (urlR.toLowerCase().indexOf("pts2") === -1 && urlR.toLowerCase().indexOf("srs") === -1 && urlR.toLowerCase().indexOf("pts_faq") === -1 && urlR.toLowerCase().indexOf("srs_faq") === -1) {
  //SRS and PTS2 are not present in http referrer
}

//Else if srs & srs_faq & pts_faq are not present, Redirect to pts_faq because redirecter must be coming from pts2
else if (urlR.toLowerCase().indexOf("srs") === -1 && urlR.toLowerCase().indexOf("srs_faq") === -1 && urlR.toLowerCase().indexOf("pts_faq") === -1) {
  window.location.replace("http://pbc/qa_faqs/pts_faq.html");
  //Redirects users to pts_faq
}




如果需要更多信息,请告知我们。

0 个答案:

没有答案