[thelist] Back button issue with QueryString

Joshua Olson joshua at waetech.com
Thu Jan 23 09:34:01 CST 2003


----- Original Message -----
From: "Michael Robertson" <mike at mikeemedia.com>
Sent: Thursday, January 23, 2003 9:59 AM


> Basically this part of the QueryString  "?msg=23" tells the server to call
a
> sub that pulls the corresponding message from a database and displays it
in
> the browser. That is working fine.
>
> The problem is if follow I link to another page and decide I want to go
back
> and hit the back button, the browser history calls
> MyPage.asp?msg=23 and displays the message again which in most case is not
> appropriate anymore.
>
> So I'm wondering if there is a way to eliminate that problem.

Here's a completely ridiculously complex way to deal with this:

1.  Change the display code so that the error message is generated via JS
using document.write instead of being inserted into the HTML directly.

2.  Set a cookie indicating that the message has already been displayed.

3.  Check for this cookie prior to actually calling the document.write.  If
the cookie exists, do not display the text.

This technique could work, but opens up a vast array of cans of worms.

Here's another technique:

Use session variables to make sure that the message is only displayed once.

This would not work too well if the file came directly out of the users
cache instead of being reloaded from the server.  Adding the appropriate
headers to force the page to not be cached may help in this case.



In a nutshell, what you are trying to do is basically impossible without JS.
With JS, you could also use the location.replace function to make it so that
the page that is concerning you get overwritten with the following page.


I have other ideas too... ask if you need them.

HTH,

-joshua




More information about the thelist mailing list