Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    history object and href tag

    Hi, I know very little about javascript, and want to be able to redirect a user back to their referring page through a link. The page will be a .php file. I understand the history object and either back() or go methods should send them back if they click the link, but I'm having no luck. The link is as follows:
    <a href="javascript:;" onClick="history.back()">Follow this link</a>

    I've also used "history.go(-1)" to no avail. I've tested to see if history.length>0 and it tests positive. Any help on the syntax for this would be greatly appreciated.

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    onclick="location=document.referrer;"

    The history object is not always reliable in this case.

  • #3
    New Coder
    Join Date
    Feb 2003
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, when I changed the href value from "javascript:;" to "#" the history.back() method worked.

    I do have a question though, I am directing people to a file on one website from several other websites. The file has a "back" link, as well as a couple of other links that are basically "refresh" links that reload the page with certain variables depending on the button selected. Of course, if they do this several times, they have to hit the "back" link several times to go back to where they started.

    Is there a simple way to capture the referring website when they initially come to the page, and store that as a variable, to be used when they select the "back" button. I work with php primarily, not javascript, so I dont' know how to capture a javascript variable and store it as an html variable to be passed to the form as it reloads, until visitor ready to go back to their original site. Any ideas? Thanks for any help you can give me.


  •  

    Posting Permissions

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