[thelist] Back button issue with QueryString

Chris W. Parker cparker at swatgear.com
Thu Jan 23 10:56:01 CST 2003


michael,

joshua's idea is pretty good. however it's not impossible to do without
javascript like joshua said.

1. submit form on page1 to page2
2. process form from page1 on page2
3. set a cookie on page2 stating that a message has not been displayed.
Response.Cookies("errordisplayed") = "no"
4. send them back to page1 with the error querystring
5. check the cookie before any output is written to the page. if the
cookie is "no" rewrite the cookie to be "yes" and continue with normal
processing, if the cookie is "yes" don't process the error but instead
display the page as it would normally appear.
6. kick up ya shoes and relax your feet, party on down to the xscape
beat.

this will work fine as long as cookies are enabled. if cookies are not
enabled* you could always use the session variable. i've never used this
feature so i don't know how it works exactly.

hth,
chris.

*you can check to see if cookies are enabled by trying to set a cookie
and then retrieving it. if you cannot retrieve it, it was not accepted
by the client.


Joshua Olson <mailto:joshua at waetech.com> wrote:

> ----- 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