Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
-1
rated 0 times [  1] [ 2]  / answers: 1 / hits: 24353  / 15 Years ago, wed, july 8, 2009, 12:00:00

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


Thanks, -Pete


More From » redirect

 Answers
23
if (document.referrer != ) {
var referringURL = document.referrer;
var local = referringURL.substring(referringURL.indexOf(?), referringURL.length);
location.href = http://page.com/login + local;
}

[#99166] Friday, July 3, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stefanicarolinat

Total Points: 145
Total Questions: 91
Total Answers: 93

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
stefanicarolinat questions
Mon, Nov 15, 21, 00:00, 3 Years ago
Fri, Apr 16, 21, 00:00, 3 Years ago
Thu, Oct 15, 20, 00:00, 4 Years ago
Fri, Jul 17, 20, 00:00, 4 Years ago
;