View Full Version : "If you came from page1.htm - you'll be redirected to page3.htm"
Perka
06-12-2011, 04:58 PM
Hello!
I would be very thankful if someone could help me with a script like this:
"If you came from page1.htm - you'll be redirected to page3.htm" (within a specified amount of time).
I have searched for some code for this but haven't found it...
Really hope someone can help!
Thanks/Perka
Perka
06-12-2011, 06:02 PM
Hrm, I found this example, but it only seems to work with the complete URL:
----------
if (document.referrer == "http://www.z.com/x.htm")
{do whatever}
else if (document.referrer == "http://www.z.com/y.htm")
{do something else}
----------
Can it be modified to work with only "x.htm"?
if(document.referrer == "http://blah.com/x.html"){
// do whatever
}
Perka
06-12-2011, 08:51 PM
if(document.referrer == "http://blah.com/x.html"){
// do whatever
}
Thanks, but will this work if I only write "x.html" (without the full url)?
djr33
06-13-2011, 01:19 AM
No. You will need to see if the string "x.html" is contained within the URL or, perhaps more specifically, if it ends with it.
Since that's a little complicated (but possible), you can try the following method:
if(document.referrer == "http://blah.com/x.html" || document.referrer == "http://other.com/x.html"){
List as many as you need, separated by the || (or) symbol.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.