View Full Version : Calling History On Load

03-12-2004, 08:26 PM
Can anyone show me the command to interact with the document history on loading a page. I have a project where the user must navigate through several pages, selecting filtering criteria as they go. On the final page, they input the info we need to record. On submission, we use ASP to save the data, then display an "Okay" button and notify them their data was saved. The button uses the document.history function to back them up 3 or more screens to the second page of the site, where they can begin selection criteria again as needed.

It would be a lot easier if this were done automatically. We save the data before the form displays. It would be easy to call a function onload, but I am not sure of the syntax needed.

We do not want to use a Redirect command, we want to keep the history intact so when the hit their back button, they are not going back to submitted forms

03-13-2004, 10:35 AM
well, if i read that correctly, then you want a page that does nothing but send the user back three or four pages.

if that's what you're looking for, then the following should do what you want:

<html><head><script>window.onload = function() { history.go(-4); }</script></head></html>

if that's not what you were looking for ( and i'm pretty sure it's not ) then you're gonna have to explain it again.

03-13-2004, 01:50 PM
Thanks, that was exactly what I was looking for. We are calling that page to save values entered on the previous page. After all the logic is performed that determines what to save and how to save, we just wanted to take them back to the second welcome screen in the application. From there, if they pressed the back button, we wanted to take them to the screen they were on prior to that. A redirect command would not have done this, that is why we wanted the history function called on load.

Also, we store a value that records every time they refresh their screen, so the value needed for the history screen would change depending on what was done on the data entry screen.

Willy Duitt
03-13-2004, 02:45 PM
Try using location.replace() which will not load the links into the browser history.

<a href="javascript&#58;location.replace('http://www.yahoo.com')">yahoo</a>


03-15-2004, 04:18 PM
This has become my favored web site, chances are if I am on the internet it is because I am headed here for help. Without the info I receive here, I would probaby be unemployed.

03-15-2004, 10:07 PM
better make sure your boss and co-workers don't find out where you get your info, or you'll lose your job security. ;D