【问题标题】:How to prevent a form re-submission on clicking reload button in HTML如何防止在 HTML 中单击重新加载按钮时重新提交表单
【发布时间】:2018-08-24 13:18:03
【问题描述】:

当我在各个字段中输入数据并单击提交按钮时,表单已提交,当我单击重新加载按钮时,它会显示以下消息“您正在查找的页面使用了您输入的信息。返回该页面可能会导致重复您执行的任何操作。要继续吗?如何防止此表单重新提交,因为单击重新加载按钮时我想刷新页面。这是 HTML 表单。

<!DOCTYPE html>
<html>

<head>
  <title> Sample Page </title>
</head>

<body>
  <form id="login-form" method="post">
    <input type="text" id="user-name" name="Username" placeholder="USERNAME" maxlength="15" autocomplete="off"> <br> <br>
    <input type="password" id="pass-word" name="Password" placeholder="PASSWORD" maxlength="10" autocomplete="off"> <br> <br>
    <button id="login-button" name="login_button" type="submit"> Login </button>
  </form>
</body>

</html>

【问题讨论】:

标签: html


【解决方案1】:

我找到了一个很好的网站here 来解释它,但基本上你需要使用&lt;form action="file.html"&gt; 将数据发送到另一个页面,然后在那个文件中,你有这个元素:

<meta http-equiv="refresh" content="0; URL='original-file.html'" />

这将在 0 秒后将您重定向到原始页面,即上面有表单的页面,并且该页面可以在没有该问题的情况下刷新。

【讨论】:

    猜你喜欢
    • 2019-06-24
    • 2013-02-20
    • 2011-12-06
    • 1970-01-01
    • 2021-03-01
    • 2017-12-13
    • 1970-01-01
    • 2012-03-21
    • 1970-01-01
    相关资源
    最近更新 更多