Page 1 of 1
Disable Back Button
Posted: Sat May 18, 2002 8:00 am
by Hebbs
That got your attention didnt it!
Whilst I am aware you cant do this, I want to include a Javascript function that pops up an error message when selecting the back button on certain pages.
I dont want users resubmiting info in one or two scripts by going back then forward again.
Any thoughts?
Hebbs
Posted: Sat May 18, 2002 9:46 am
by DSM
Code: Select all
//cache control
if ($REQUEST_METHOD=='POST') :
header('Expires: ' . gmdate("D, d M Y H:i:s", time()+1) . ' GMT');
header('Cache-Control: Private');
endif;
//end cache control
This should stop form info from reposting if vermin, I mean visitors try using the <<Back/Forward>> buttons.
Back control continued
Posted: Sat May 18, 2002 10:40 am
by Hebbs
Thanks DSM but can you clarify this some more for me?
What should the result be and where does it exactly go in relation to the <head>, <body> of the script etc.
I need to be able to return to the page as I have some error checking that sends the user back when they forget info or put in the wrong data.
My original line of thought was a Javascript reaction that told them not to be stupid and leave the BACK button alone!
Hebbs
Posted: Sat May 18, 2002 10:51 am
by jason
Hebbs, you would put the above header statements AFTER all error checking. Basically, if all the data is valid, then you put those statements.
Note, make sure you don't have ANY HTML or spaces (you don't output anything) before the header() functions.
Posted: Mon May 20, 2002 8:55 am
by ILoveJackDaniels
I could be wrong (heheh, wouldn't be the first time

), but I think the back button can appear disabled if you want, using a META REFRESH tag with a delay of zero seconds. While that does not actually
disable the back button, it does give that appearance, as when the user clicks on it they go nowhere....
Code: Select all
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=http://www.yoursite.com/newpage.html">
Posted: Tue May 21, 2002 9:22 pm
by volka
jepp, but this wouldn't stop me from using the drop-down-history of my back-button

Posted: Wed May 22, 2002 3:06 am
by ILoveJackDaniels
Ok, how's about this then .... a javascript triggered by an onload function in the body tag, that opens the required page in a new window then closes the current window...?
Only problem with that one ie IE's new 'feature' that asks for confirmation before closing windows......
Posted: Wed May 22, 2002 6:29 am
by jason
I still think the header() approach is the best one. Works all the time.
Posted: Thu Jun 27, 2002 4:49 am
by 9902468
DSM wrote:Code: Select all
//cache control
if ($REQUEST_METHOD=='POST') :
header('Expires: ' . gmdate("D, d M Y H:i:s", time()+1) . ' GMT');
header('Cache-Control: Private');
endif;
//end cache control
This should stop form info from reposting if vermin, I mean visitors try using the <<Back/Forward>> buttons.
Exactly how this works? I've set these headers:
Code: Select all
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
What
Code: Select all
header('Expires: ' . gmdate("D, d M Y H:i:s", time()+1) . ' GMT');
actually does and what
means? I want to prevent any caching, are these prevent back buttoning headers going to do some harm to that?
Posted: Thu Jun 27, 2002 7:19 am
by e+
A word of warning for anyone thinking about using a javascript refresh for anything if you set it to less than 5 seconds googlebot won't follow it as it will think it's spam, not a major upset but something to be aware of.
I solved a similar problem by passing a hidden variable in the form called used and set it to 1 once someone submitted the form. If there was an error and they needed to go again it was reset to 0. It’s a bit simple but I like simple.
