我有一个表格,其中有一个 target
,并且我希望在提交后仅将表单替换为目标页面,而不是整个页面。我将表格包装在 <frame>
中标签,但在提交表单后,整个页面都会重新加载表单提交目标,而不仅仅是表单本身(包含在框架标签中)。
无论如何让表单提交只替换那个框架。理想情况下,浏览器中的 URL 不会改变。
最佳答案
您可以像这样使用 iframe。 如果您将 iframe 设置为表单的目标,响应将被重定向到 iframe。
You just have to use iframe's name as the form's target attribute.
<form id='myform' action='action.php' method='POST' target='formresponse'>
<label for='name' >Your Full Name*: </label><br/>
<input type='text' name='name' id='name' maxlength="50" /><br/>
<label for='email' >Email Address*:</label><br/>
<input type='text' name='email' id='email' maxlength="50" /><br/>
<input type='button' name='Submit' value='Submit' />
</form>
<iframe name='formresponse' width='300' height='200'></iframe>
http://www.html-form-guide.com/web-form/submit-form-multiple-scripts.html
关于html - 在框架中提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36348476/