Disable Back Button
Moderator: General Moderators
Disable Back Button
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
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
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 controlBack control continued
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
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
- ILoveJackDaniels
- Forum Commoner
- Posts: 43
- Joined: Mon May 20, 2002 8:18 am
- Location: Brighton, UK
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">- ILoveJackDaniels
- Forum Commoner
- Posts: 43
- Joined: Mon May 20, 2002 8:18 am
- Location: Brighton, UK
Exactly how this works? I've set these headers:DSM wrote:This should stop form info from reposting if vermin, I mean visitors try using the <<Back/Forward>> buttons.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
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");Code: Select all
header('Expires: ' . gmdate("D, d M Y H:i:s", time()+1) . ' GMT');Code: Select all
header('Cache-Control: Private');
Last edited by 9902468 on Fri Jun 28, 2002 12:37 am, edited 1 time in total.
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.
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.