HTML - 刷新后保持输入值 [英] HTML - input value kept after Refresh

查看:658
本文介绍了HTML - 刷新后保持输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当在HTML页面上进行刷新时,会保留输入字段的值(除非您按Ctrl + F5键)。

是否有标题或其他类型的设置,可以改变这种行为,而无需在表单上输入任何东西或输入自己?

我有一个网站,输入值不会保留在页面之后在生产中刷新。然而,当我在本地机器上测试这段代码时,我没有这种行为。

如果您设置 autocomplete = off ,内容将永远不会被存储。



另外,有很多方法可以通过javascript完成,具体取决于正是你想要完成的事情,无论是清除整个表单(使用reset()方法)还是重置单个字段。

Usually, when a refresh is made on an HTML page, the values for input fields are kept (unless you do Ctrl+F5).

Is there a header or other type of setting than can change this behavior, without chaging anything on the form or input itself?

I have a site where the input value is not kept after a page refresh in Production. However I do not have this behavior when I test this code on my local machine.

解决方案

If you set the attribute autocomplete=off, the content will never be stored.

Alternatively, there's a plethora of ways to accomplish this with javascript, depending on exactly what you want to accomplish, whether it be clearing the whole form (use the reset() method), or resetting the single field.

这篇关于HTML - 刷新后保持输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆