在 iframe 中提交表单并重定向整个页面 [英] submitting the form in iframe and redirect the whole page

查看:27
本文介绍了在 iframe 中提交表单并重定向整个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我有一个简单的问题,我还没有找到正确的答案.我的页面中有一个来自外部域的 iframe.提交此 iframe 内的表单后,我想重定向整个页面,而不仅仅是 iframe 内的内容 - 我想实现的正确方法可能是通过目标"属性.
示例 html:

i guess I have an easy question, I have not found the right answer yet thoguh. I have an iframe in my page that comes from external domain. After submiting the form which is inside this iframe, I would like to redirect the whole page, not just content inside the iframe - i guess the right way to achieve might be via "target" attribute.
The sample html:

<html>
  <body>
    <h1>main page</h1>
    <iframe src="http://example.com">
      <form url="http://example.com/action">
        ...
      </form>
    </iframe>
  </body>
</html>

提交表单应该向我显示将 POST 请求作为新页面提交的结果(不在 iframe 中)

submitting the form should show me the result of submiting the POST request as a new page (not in the iframe)

推荐答案

我已经将 target='_parent' 放在 iframe 中,但我最初还没有在 form 元素.将 target='_parent' 属性添加到 form 后,它开始按预期工作.

I have put target='_parent' in the iframe but I haven't done this initially in the form element. After adding target='_parent' attribute to form it started to work as expected.

这篇关于在 iframe 中提交表单并重定向整个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆