How do I use javascript to tell me which link brought me to my current page?

Discussion in 'JavaScript' started by gregsby, Aug 9, 2010.

  1. #1
    Hi,

    I have a home page with basic links to anchored sections of a second page.

    On the second page i have some content which contains a variety of functions that will run depending on which link the user clicked from the home page.

    My question is what javascript can I use on the second page which will identify the link used from the home page.

    Thank you
     
    gregsby, Aug 9, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <script type='text/javascript'>
      document.write(document.referrer);
    </script>
    
    Code (markup):
    Sometimes it shows nothing because visitors can stop their browsers from sending the referrer value.
     
    Cash Nebula, Aug 10, 2010 IP
  3. gregsby

    gregsby Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for that - i'm experimenting with parsing a query string on my anchored links. Will update.
     
    gregsby, Aug 11, 2010 IP