如何控制浏览器刷新之后不保留表单内未提交的内容?

WBOY
Release: 2016-06-06 20:52:19
Original
936 people have browsed it

遇到一个问题,firefox下表单输入内容之后不进行提交直接刷新,输入的内容还会出现在表单里。
找了一些禁止缓存的header写法,但是都没有效果。

因为页面上有其他元素是javascript根据表单内容的change事件动态生成的,这样的就导致页面刷新之后内容异常,需要进行初始化,不知各位如何处理这个问题,位指点。

回复内容:

遇到一个问题,firefox下表单输入内容之后不进行提交直接刷新,输入的内容还会出现在表单里。
找了一些禁止缓存的header写法,但是都没有效果。

因为页面上有其他元素是javascript根据表单内容的change事件动态生成的,这样的就导致页面刷新之后内容异常,需要进行初始化,不知各位如何处理这个问题,位指点。

可以给表单域加上autocomplete属性,值等于off
<input type="text" autocomplete="off">
或者给form加也可以,作用于整个表单
<form autocomplete="off"></form>

相关资料:
https://wiki.mozilla.org/The_autocomp...
http://www.whatwg.org/specs/web-forms...

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!