IE will save the contents of the form on the back button, and then:
- you didnโt violate caching with a pragma without a cache or the like
- the form fields in question were not dynamically created by the script
You seem to have caching in hand, so I guess the latter can be applied. (According to mkoeller, Firefox avoids this problem if the page is in the last few reverse clicks, keeping the page alive longer than it is on the screen. However, this is not necessary, and Firefox will return to the same behavior as IE and other browsers as soon as you looked a few pages ahead and the old one expired.)
If you create your own form fields from the script onload, then the browser does not know that the new input control is โthe same as the old instance, so it cannot fill its previously submitted value. In this case, if you want it to be good played using the back button, you should start storing data on the client.
Then you need to use some kind of status key so that each data set is bound only to one page instance, otherwise, through several instances of the same form or with two open browser tabs in the form, your script will be very confused right away.
And then you begin to collect a lot of data, if they are large forms, and if the client storage mechanism that you use is cookies, you can start to lose data, and also send unnecessary load to the state nonsense with every HTTP request. Other client-side storage engines are available, but they are browser dependent.
In short: making dynamically generated forms is a huge pain, and probably best avoided if you can. Having a hidden form on the page that the script creates allows the browsers to do their magic of remembering fields instead of giving you a task, usually a lot easier.
bobince Nov 04 '08 at 11:16 2008-11-04 11:16
source share