[thelist] JavaScript: the Back Button

.jeff jeff at members.evolt.org
Mon May 13 14:51:01 CDT 2002


> From: Tab Alleman
> Argh surely somebody's done something like this before.
> I want to make it so that when a user clicks the Back
> Button on their browser, it sends them back 2 pages
> rather than 1.
> Why?  Because they just came from a page that had an
> invisible script that redirected them here.  The
> invisible script sent them here via a <body onload=
> document.forms[0].submit();>  Clicking back from Page
> 3 takes them to page 2, which then sends them back to
> Page 3.  I want the back button to send them back to
> page 1.
> So if you're thinking there's another way to skin this
> cat, you may be right.. but I need for my invisible
> script to send variables to page 3 in the FORM object,
> not the querystring.  Page 2 is an ASP script, by
> the way, in case that helps.

you're trying to solve the wrong problem.

instead of trying to fix the problem caused by submitting a hidden form, fix
the situation that causes you to need that hidden form.  otherwise, you'll
never solve the problem completely and will have users munging up your data
constantly with their back button.

in your processing page for the first form, you need some base logic like

' process contents of form
<% asp blah %>
' do we have additional data to process?
If foo = "bar" Then
  ' do the additional processing in the same script
  <% do more asp blah %>
End If

do *not*, i repeat *not* send the process back to the client and auto-submit
to the next processing page.  that will be no end to your grief as you're
finding out now.

good luck,


jeff at members.evolt.org

More information about the thelist mailing list