Re: How To Disable A Browser's Back Button in CGI.pm?
by Masem (Monsignor) on Apr 10, 2001 at 22:49 UTC
|
Disabling the back button, for whatever reason, is very very very very bad web design. The history feature most browsers carry is one of the strong points of the web (being able to go back to where you came from previously), and those that try to disable it for whatever reason and by whatever mean (opening a new window, or using JS), find themselves easily bitten by keyboard commands or other features.
That said, if you don't want a form to be reposted after a user leaves it, assign a unique session id that is generated when you first give the user the form and stored as a hidden field within it. When the form is submitted, toggle this sessionid as 'done', and if the form is resubmitted, you can easily check if that session id has already been procesed or not. (Similar to other ideas already posted).
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
| [reply] |
(jeffa) Re: How To Disable A Browser's Back Button in CGI.pm?
by jeffa (Bishop) on Apr 10, 2001 at 22:34 UTC
|
Sure, tie the user down!!
Can't do it - you _could_ present the form as another
window via JavaScript and remove the location bar, menu
stuff, ect. - but then you just open yourself up to the
two flavors of JavaScript: IE vs Netscape. Don't forget
to disable the right click (if it can be done), else your
more clever users will just right click and select 'Back'
from the pop-up menu. Oh, and disable the keyboard to, else
your even more than clever users will just hit
Alt-Left Arrow :P
Jeff
R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--
| [reply] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by suaveant (Parson) on Apr 10, 2001 at 22:38 UTC
|
Probably the best thing to do is to generate a count, and put
it in all the links, and remember what page had the last count.
If they go back, and click an old link, it will have an old count,
you can then slap them and tell them to go back where they
belong, and ignore any data they may have tried to re-post.
But disabling back is impossible to my knowledge... but even
if it is possible, it probably isn't worth the hassle.
- Ant | [reply] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by little (Curate) on Apr 10, 2001 at 23:13 UTC
|
As others said before: DON'T
cause of many reasons.
But instead what about heavily using JavaScript to open a new window for each form you want just one by one and when the user once submitted the window will close and the focus will go back to your mainWindow.
so it'S alike :
windows open focus has event
============ ============= =====
index.html index.html user clicks "register now"
open new Window f1
index.html newWindow f1 user fills out the form
newWindow f1 and submits (newWindow closes)
index.html index.html open new Window f2
index.html newWindow f2 user fills out the form
newWindow f2 and submits (newWindow closes)
index.html index.html
Well and here comes the interesting part, cause instead of index.html the browser could point to your script. Ok, it's a quick and dirty idea but I guess it's worth a try.
Have a nice day
All decision is left to your taste | [reply] [d/l] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by Coyote (Deacon) on Apr 10, 2001 at 23:32 UTC
|
I agree with the sentiment expressed in some of the other replies. Messing with the user's browser is a bad idea. However if you still want to do it, you can use a bit of javascript, location.replace("http://your.url/something.cgi?myparams=somthing") as your form action or as an onSubmit handler.
----
Coyote | [reply] [d/l] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by voyager (Friar) on Apr 10, 2001 at 23:56 UTC
|
Ditto what Coyote said. Don't try to control the user's behavior. The back button is the second most used control (after clicking a link) on the web.
I'm sure you have a good reason for not wanting the user to click back, but you should probably change your design to allow for it. One of the nice things about the web is that you know you can follow a link and always get back to where you are. If you keep then from going "back" to your page, you keep them from going "back" anywhere. What then? Make them close the browser? | [reply] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by traveler (Parson) on Apr 11, 2001 at 00:28 UTC
|
Assuming what you want is to prevent the user from repeating the form, how about
sending the user a cookie saying that he/she'd already submitted
the form? You could try setting "Pragma: no-cache" on the calling
page and then using a cookie on that page, but that is less reliable
and some browsers/caches seem to ignore "no-cache".
--traveler | [reply] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by dws (Chancellor) on Apr 11, 2001 at 03:56 UTC
|
If you're really, really set on preventng a user from being able to back into a dynamically generated page, send
Pragma: no-cache
in the HTTP header the prefixs the HTML. IE, at least, will honor this, though the results are ugly. You might also try
<meta http-equiv="Pragma" content="no-cache">
Play around with these and see if they meet your needs.
| [reply] [d/l] [select] |
|
|
| [reply] [d/l] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by zakzebrowski (Curate) on Apr 11, 2001 at 01:51 UTC
|
I actually have no value added content here to the actual solution. However, a simple aproach would just to tell the user *not* to do that. Also, (in an ideal world) if the user hit the back button and hit forward again, the program should be able to recover. (For a db app, rather than just using inserts, first select and update/insert depending on appropriate case.)
Zak | [reply] |
Re: How To Disable A Browser's Back Button in CGI.pm?
by sierrathedog04 (Hermit) on Apr 11, 2001 at 19:06 UTC
|
Thanks to everyone who dissuaded me from the Javascript no-back-button solution.
It turned out that there was a coding error which only showed up when the user hit the back button. My script stores a CGI.pm query object on Page 2 and then retrieves and deletes it on Page 3.
However, users who hit the back button on Page 3 to return to the form on Page 2 and then resubmitted got an error, because some of the CGI variables stored in the CGI query object no longer existed.
The proper solution turned out to be to check that a stored query object exists, and provide the user with a helpful warning message if it does not. The advantage of this approach is that the browser's back button still works the same way as it always does, and the user knows what is going on.
| [reply] |
|
|
Yes you effectively can,
this works every time:
<SCRIPT LANGUAGE="JavaScript">
//always go forward
window.history.forward(1);
</script>
| [reply] |