html - 在框架中提交表单

标签 html frames

我有一个表格,其中有一个 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

MDN Form target

关于html - 在框架中提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36348476/

相关文章:

php - 使用 PHP 登录不显示任何 html 代码

jquery - IE6 框架和内存泄漏

html - 无法使用 id 选择器更改 Bootstrap h1 文本颜色?

html - @media 查询不适用于 Android 手机 (Chrome)

HTML5 图片说明 : Image moves to next row

PHP 注销脚本,框架集中有 4 个框架

javascript - 如何指定哪些内容脚本将在 all_frames 上运行,哪些不会?

css - 在不移动 div 的情况下在 div 中四处移动文本

javascript - 在多个框架中使用变量

html - 如何设置 HTML 框架的背景颜色?