我有一个针对 _blank
的 HTML 表单.我希望表单所在的页面在提交后重新加载。
下面是一些示例标记:
<form method="POST" action="result.php" target="_blank">
<label for="name">Name:</label>
<input type="text" name="name" />
<label for="email">Email:</label>
<input type="email" name="email" />
<input type="submit" value="submit" />
</form>
因此,当您提交此表单时,它将 POST
至 result.php
在新窗口或标签中。这使表单页面保持原样。我希望重新加载表单页面,或者至少重置所有字段。
我试过了 <form onsubmit="location.reload()"...
以及onsubmit="window.location.reload()"
但没有任何改变。
有什么建议吗?
(请不要使用 jquery)
最佳答案
不确定为什么 window.location.reload()
不起作用。我认为应该。但是,这似乎确实有效:
onsubmit="setTimeout(function () { window.location.reload(); }, 10)"
关于javascript - 表单提交到 _blank 后如何刷新表单页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18920651/