Mozilla Firefox form values reset on history.back

社会主义新天地 提交于 2019-12-10 18:08:35

问题


I'm writing a PHP script. I've got a form uses post method and action to another page. If an error occurs, I show a message on that target page, and let the user go back via a link that triggers history.back(); javascript function. So user clicks that link and turns back to the page includes form and values entered by user should remain in inputs.

They stay on Chrome, but lost in Firefox. Is there a way to keep DOM information on all major browsers using history, or is the only way to do that is to use a cache like session, cookies, etc. ?


回答1:


You could, and I know it's annoying, capture your POST data and turn it into SESSION variables, then repopulate input fields on browser back.

Alternatively, You can submit the form to an iframe and process, or use ajax to process and depending on the result, trigger a new page load or not.



来源:https://stackoverflow.com/questions/16664904/mozilla-firefox-form-values-reset-on-history-back

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!