无论如何,是否有使用JavaScript来获取引用URL的方法,比如说引用URL是http://page.com/home?local=fr,然后将用户重定向到与引用页面具有相同本地名称的新页面(http://page.com/login?local=引用本地)?

伪代码将是这样的:

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;
}

关于基于引荐来源的JavaScript重定向?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1098877/

10-11 13:27