IT技术博客大学习 共学习 共进步

阻止Firefox缓存input的值

记事本 2010-08-05 10:02:32 浏览 1,781 次

在Firefox里面input的值会被缓存起来,刷新页面之后,会恢复成刷新之前的值。有的时候我们并不希望这么做,可以用autocomplete=”off”来阻止Firefox的默认机制。

比如下面的代码,在刷新页面之后input的值全部为空。

以下是代码片段:
<form>
<input autocomplete="off" type="text" /><br />
<input autocomplete="off" type="text" /><br />
<input autocomplete="off" type="text" /><br />
<input autocomplete="off" type="text" /><br />
</form>

为了方便也可以这样写:

以下是代码片段:
<form autocomplete="off">
<input type="text" /><br />
<input type="text" /><br />
<input type="text" /><br />
<input type="text" /><br />
</form>