Reload a page when back button pressed

R

Rob

I know this is an old one, considering how many posts I found on it but I
just wondered if any best practises had popped up recently, especially as
Ajax has increased JavaScript and DHTML's importance.

I'm writing a database application. I like pop-up boxes so I've implemented
one on my webpage using a floating DIV. The logic goes like this:

1. When the page is rendered (on the server), it adds "var DisplayPopup =
false;" in the page
2. A JavaScript function in the page checks this variable and sets the style
of the popup DIV to hidden or visible as required
3. The user bashes in some data and hits the SAVE button
4. Postback occurs and validates the form. If there is an problem, the text
inside the HTML is updated with the validation message
5. When the page renders (on the server) this time, it adds "var
DisplayPopup = true;" in the page
6. Same JavaScript function as above notices this and sets the style to
visible

On the popup there is an OK button which simply triggers another JavaScript
function to set the style back to hidden.

Works a treat - most of the time!!

It fails if the user goes to another page (say a static HTML page) and then
presses the back button.

The browser (IE7 in this case) retrieves the page from the cache. This
cached page has "var DisplayPopup = true;" in there so when the JavaScript
runs again, it displays the popup.

All I want to be able to do is *somehow* instruct the browser that it should
never get this page back from the cache, but should always get it from the
server. Now I think there are a collection of various page expiry settings
that might help here but I wondered if these also prevent resources from
within the page from also caching? I don't want this to happen - just reload
the ASPX page itself. I don't want it to not cache images etc.

It would be really neat if there was some JavaScript way of persisting
variables in the cache. I know about cookies but don't particularly want to
have to use those for this simple requirement.

Thanks, Rob.
 
B

bruce barker

you set your page to expire (so it can not be pulled from the cache).
also if you look at google's web tool kit's browser history management
object, to see what others are doing.


those that have not yet looked at google web toolkit should. instead of
being server based spewing javascript, its browser based with ajax calls
to the server. this means all the controls are client based with client
script apis and properties.

they also have a java to javascript compiler that is also interesting.


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top