I have a page with a form where many of the fields are populated from variables passed in the URL. Those fields are disabled (NON-EDITABLE) and are only there for the user to view.
The remaining fields require user input and are NOT disabled (EDITABLE). When the form is submitted a confirmation page comes up. It may be the case that the user needs to submit several of these forms where the NON-EDITABLE information is identical from form to form, so being able to go back to the form page from the confirmation page would save a lot of time.
The way I want this to work is when a user presses the back button all the NON-EDITABLE fields are populated, but the EDITABLE fields are blank. This is what Firefox is doing, but IE8 is does not "forget" what has been entered in the EDITABLE fields.
To disable the cache the following appears at the beginning of my page AND at the end of my page.
<head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-store"/>
<head/>
What more must I do to make IE forget what was entered in the EDITABLE开发者_如何转开发 fields when the back button is pressed?
All of my pages are generated with PHP if that matters.
EDIT:
It appears to me that this is a problem of IE caching my page even though I have told it not to. Are my meta
tags correct? Do I need to do something else to prevent IE from caching my page?
Have you tried adding the autocomplete='off'
attribute to your form fields?
eg something like this:
<input type='text' name='myfield' size='10' autocomplete='off'>
I found this code snippet and it seems to do what I want.
<input type="hidden" id="refreshed" value="no"/>
<script type="text/javascript">
onload=function(){
var e=document.getElementById("refreshed");
if(e.value=="no"){
e.value="yes";
}
else{
e.value="no";
location.reload();
}
}
</script>
UPDATE:
The above solution worked in IE, but I found it didn't work right in Firefox. Exploring the situation further I finally figured my issues out with some SO help. Below is a better solution, put it ABOVE your DOCTYPE
header. More details here.
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
?>
Why not just do a redirect back to the form instead of making them hit the back button (have a link saying "Enter More" that leads back to the form)?
This way when the page loads you can have your inputs default to a blank value
example
<input type="textbox" name="somename" value="">
精彩评论