Results 1 to 5 of 5

Thread: "If you came from page1.htm - you'll be redirected to page3.htm"

  1. #1
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default "If you came from page1.htm - you'll be redirected to page3.htm"

    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

  2. #2
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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"?

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Code:
    if(document.referrer == "http://blah.com/x.html"){
      // do whatever
    }
    Jeremy | jfein.net

  4. #4
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Nile View Post
    Code:
    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)?

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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:
    Code:
    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.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •