View Full Version : history object and href tag

02-23-2003, 12:56 AM
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.

02-23-2003, 01:48 AM

The history object is not always reliable in this case.

02-23-2003, 01:55 AM
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.