View Full Version : Stop page from being added to the history
02-26-2003, 03:40 PM
I need to stop a page being added to the history as it is being loaded. Is there a quick and easy way of doing this.
I'm sure I've seen this done somewhere before but I cant find anything on it now.
02-26-2003, 04:05 PM
02-26-2003, 04:24 PM
I need the browser to display the page but make it look to the browser that that page had not been opened. I cant specify an url because I don't want the page to be reloaded I just need to move back to it in the history.
so when I click the back button it takes me back to the page I was on previously before.
the problem is is that the page I dont want recording in the history may be re loaded more than once. when I click the back button I need it to take me back to the page previous to the one that I dont need loading.
If that makes sense.
02-26-2003, 05:20 PM
Sorry, but no, it makes no sense ;)
Why don't you use an example or explain why do you want the page to be loaded, reloaded, opened or whatever...?
02-26-2003, 05:27 PM
location.replace will replace the current page in the browser's history with a new one (and display the new one); you can also skip over pages in the history, with things like history.go(-2); but that's the full extent of your control over history recording - you cannot affect what happens in the history when the back button is pressed.
Why do you need this? I've seen hundreds of posts asking how to manipulate history, and in %99.9 of cases there was another answer.
02-26-2003, 05:28 PM
page 1 (this links to a page with a form)
page 2 (page contains a form with a combo box which reloads the page, this can be done multiple times)
when page 2 is submitted it brings up page 3 which tells the user that the form has been sent. at the bottom of the page is a link to move back. now I need the link to go straight back to page 1 no matter how many times page 2 has been displayed. I cant link directly to the page as it is an asp page that requires values passed from the previous page so I need to step back in the history.
Its a weird setup but its the only way it can be done as the pages are communicating with a foxpro com compontent at the back end and I need to keep the flow of values which would be lost if I simply reloaded the page.
I hope that makes a little more sense.
02-26-2003, 05:30 PM
Well then history.go(-2) might server you ...
But trust me .. it's the wrong approach
- if you need to reload the processed-state of page 1 then you need page 3 to send its information back to page 1 via an automatic POST - write the information into a hidden form and POST back to page 1 with <body onload="document.forms.myform.submit()">
I think the best overall solution would be don't have a page 3 at all - after processing the data on page 2, send your user back to page 1, with a confirmation message written on that
02-26-2003, 05:39 PM
I cant use the -2 as suggested because the user may reload the page 1, 2 or 100 times.
If I can stop the history from recording the page then -1 will work all the time.
the only way I can think of doing this is to hold a counter as a session variable on the page and use this via a java function to record how many times page 2 has been displayed and then use something like
i know thats not right but you get the gist.
I'm open to any better ideas but its looking like this is the only way forward.
Thanks for your help
02-26-2003, 06:44 PM
Don't you still have access to the variables on page 3? I think the best way is to link back to page 1 and pass all the variables back to it.
02-28-2003, 08:35 AM
why can't you just settle for this link in page 3 instead of using a session variable to record how many times page 2 reloaded?
<a href="page1.htm">Back to page 1</a>
are you passing querystrings to access page 1?
02-28-2003, 10:24 AM
Page 1 is an active server page and picks up values from the previous page posted on a form to be able to run, if I just link back to the page the values will not be present and the page will not work correctly.
Thats why I need to be able to step back in the history but I need to bypass page 2 as this page enables the user to update a database at the back end and I dont want them to have to navigate past it again once it has been posted.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.