iframe提交然后重定向 [英] Iframe Submission then Redirect

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

问题描述

如何让iframe保持默认提交但将用户重定向到另一个页面。我听说我需要在服务器端进行这种重定向,但不知道这意味着什么。

How can i make an iframe keep its default submission but after redirect the user to another page. I have heard i need to do this redirection on the server side but do not know what this means.

以下是我试过但它取消了默认的iframe提交而且只是重定向。

Below is what i tried but it cancels the default iframe submission and just redirects.

function convert() {
            document.location = '/sidingsuccess';
}

onSubmit="convert();"

推荐答案

将表单提交给隐藏的iframe。

Submit form to hidden iframe.

iframe HTML:

iframe HTML:

<g:form controller="..." action="submit" method="POST" target="hidden-frame">
...
</g:form>

<iframe id="hidden-frame" style="display: none" onload="onSubmitCompleted"></iframe>

<script>
    function onSubmitCompleted() {
        window.top.location.href = <redirect url>
    }
</script>

控制器:

/*process submission */

render("<html><head><script>window.parent.onSubmitCompleted();</script></head><body></body></html>");

这篇关于iframe提交然后重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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