如何在表单提交至_blank后刷新表单页面? [英] How can I refresh a form page after the form submits to _blank?
问题描述
我有一个以 _blank
为目标的HTML表单。我希望提交表单的页面可以在提交后重新加载。
所以这里有一些示例标记:
< form method =POSTaction =result.phptarget =_ blank>
< label for =name>名称:< / label>
< input type =textname =name/>
< label for =email>电子邮件:< / label>
< input type =emailname =email/>
< input type =submitvalue =submit/>
< / form>
因此,当您提交此表单时,它将 POST
到 result.php
在一个新的窗口或标签。这样就保留了表单页面。我想要表单页面重新加载,或者至少重置所有字段。
我试过< form onsubmit =location.reload( )...
以及 onsubmit =window.location.reload()
但没有任何变化。
有什么建议?
(请不要jquery)
不知道为什么 window.location.reload()
不起作用。我认为它应该。然而,这似乎工作:
pre $ onsubmit =setTimeout(function(){window.location.reload();} ,10)
I have an HTML form which targets _blank
. I would like the page that form is on to reload after submitting.
So here's some sample markup:
<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>
So when you submit this form it will POST
to result.php
in a new window or tab. This leaves the form page as is. I want the form page to reload, or at least reset all fields.
I've tried <form onsubmit="location.reload()"...
as well as onsubmit="window.location.reload()"
but nothing changed.
Any suggestions?
(please no jquery)
Not sure why window.location.reload()
doesn't work. I think it should. However, this does seem to work:
onsubmit="setTimeout(function () { window.location.reload(); }, 10)"
这篇关于如何在表单提交至_blank后刷新表单页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!