[thelist] dynamic back button (javascript)

Chris Hayes chris at lwcdial.net
Wed Feb 9 17:51:58 CST 2005



If you rely on any screwed-up way a browser might deal with it you might
also come a cropper with  the next or any future round of updates.

Make your back button post a value / parameter that tells the receiving
script to procees the incoming params as a "back function".

ie. post all the data, just feed it back to your form.

better description: all forms post to themselves until you can confirm you
need to proceed.

It's messy but you are in control.

CH










----- Original Message ----- 
From: "Brian Cummiskey" <Brian at hondaswap.com>
To: <thelist at lists.evolt.org>
Sent: Wednesday, February 09, 2005 10:31 PM
Subject: [thelist] dynamic back button (javascript)


> Hi folks-  me again with another JS question.
>
> I'm working on a huge campaign for an internal intranet application (all
> win2k/ie6 workstations).  This is coded in classic vb/asp on the back
> and js for the client side.
>
> the web-based application is launched in a 3rd party scripter
> (basically, and IE-like environment, but no menus, back button, etc -- 
> similar to full screen mode (F11).  the Backspace, Escape, and enter
> keys are also disabled, as are right mouse clicks for navigation
> purposes [backspace and enter will still work when active on a form
> element].)
>
> I'm trying to set it up so that the "back button" - a button I
> physically put into the script - is dynamic.
>
> 1st logical answer was to use the history(-1) function.  This is exaclty
> what i want- BUT the problem lies in that IF the agent entered anything
> into the form on the page, and then goes back, the data entered is lost.
>   I need to set a cookie for it so that it will be filled in when the
> agent returns to the page once again (and doesn't look stupid asking the
> customer for the same information twice because the system lost it).  My
> pages are all set up to handel both forward and backwards movement for
> setting the cookies.
>
> My next idea was to place a hidden var on every page, using the
> HTTP_REFERRER as the value for the back button's action.  (see code
> below-  i used the same setup) This works great too--  until you want to
> go back more than 1 page.  This just puts you in an endless
> back-and-forth loop between the current page and the one just before it
> back to the orig page, and so on.
>
> So, I came up with the idea to combine the two: (with all the other code
> stripped out):
>
> <html>
> <head>
> <script type="text/javascript">
> function goBack() {
> var theform = document.getElementById("frmdefault");
> var previouspage = history(-1);
>
> theform.method="post";
> theform.action = previouspage;
> theform.submit();
> }
> </script>
> </head>
> <body>
> <form name="frmdefault" id="frmdefault">
> <input type="button" value="Back" onclick="goBack();" />
> // other form stuff here....
> </form>
> </body>
> </html>
>
>
> Well, this fails miserably.  :D  I expected it to not work.  But, I
> can't seem to think of the way to DO that, but have it work.
> firefox's JS tool (which is what i use to test/develop with) says
> "history is not a function" is the error.
>
> hrmmm...
>
>
> It's IMPOSSIBLE - not just time consuimg - to physically hard code in
> every script's previous page (probably 50+ pages by now and growing)).
> Some pages have more than 1 lead into them, so it would be a guess at
> best to send them back to one or the other.  In fact, that puts me right
> back on the HTTP_REFERER solution i tried above.
>
> Sessions are NOT an option.  This setup is used on most of our app's
> without a hitch.  However, this is the first time i've ever had
> multiple->single page paths.
>
> lol  its a big circle.  anyone have a "square" way out of it?  :P
>
> Thanks,
>
> -Brian
>
>
> -- 
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.8.6 - Release Date: 07/02/2005
>
>



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.6 - Release Date: 07/02/2005



More information about the thelist mailing list