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.
Below is what i tried but it cancels the default iframe submission and just redirects.
function convert() {
document.location = '/sidingsuccess';
}
with
onSubmit="convert();"
on the iframe code
On the server you can, after your submission is finished, use the header
function to redirect the page to another page (say example.php
) by doing:
header('Location: example.php');
is that what you're looking for?
Submit form to hidden iframe.
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>
Controller:
/*process submission */
render("<html><head><script>window.parent.onSubmitCompleted();</script></head><body></body></html>");
Replace your following line:
document.location = '/sidingsuccess';
for this one:
window.top.location.href = '/sidingsuccess';
that should do it.