基于Referrer的JavaScript重定向? [英] JavaScript Redirect based on Referrer?
本文介绍了基于Referrer的JavaScript重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无论如何使用javascript抓取引用网址,让我们说这个网址是 http:// page .com / home?local = fr ,然后将用户重定向到与reffering页面具有相同本地的新页面( http://page.com/login?local= 引用本地)?
Is there anyway to grab the referring URL using javascript, lets say the reffering url is http://page.com/home?local=fr, then redirect a user to a new page with the same local as the reffering page (http://page.com/login?local=referring local)?
伪代码将是类似这样的事情:
Pseudo code would be something like this:
var referringURL = document.referrer;
var local = referringURL.substring(referringURL.indexOf("?"), referringURL.length())
var newURL = "http://page.com/login" +local;
Send user to newURL
谢谢,-Pete
推荐答案
if (document.referrer != "") {
var referringURL = document.referrer;
var local = referringURL.substring(referringURL.indexOf("?"), referringURL.length);
location.href = "http://page.com/login" + local;
}
这篇关于基于Referrer的JavaScript重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文