Creating parent window redirect from form in iframe

Hi all,

I’m using the Iframe add-on to embed my forms in other websites - https://github.com/cedaro/gravity-forms-iframe/

Previously I was using www.typeform.com - with their embedded forms the parent page would redirect upon form submission, and this is something I’d really like to be able to do with gravity forms.

I’m not a coder, but I’ve tried adding
window.top.location.href = “http://www.example.com”;
to the script created by the iframe addon, however this just redirects the parent page as soon as it loads.

I thought perhaps I could do it by changing the functions.php file: https://docs.gravityforms.com/gform_confirmation/#4-open-the-page-or-redirect-in-a-new-tab

There seems to be a way here, I just don’t know where to add the code: https://help.surveygizmo.com/help/break-out-of-iframe

What happened when you tried that?

And also, I understand you are using the iFrame add-on to embed a form in a non-WordPres website. What do you want to do when that form is submitted?

When the form is submitted I’d like the parent window to go to a different page on the non-wordpress website where the iframe is embedded.

I will give it a go now, but I’m not sure what setting to put on the confirmations section of the gravity forms dashboard, if I am changing things from the functions.php file anyway?

If you are using the gform_confirmation filter for all confirmations, it does not matter what you select in the form builder for a confirmation: your code will override that.

As for redirecting the parent page after submission of the form in the iframe, I think you are going to be prevented from doing that due to browser security restrictions. That’s outside the control of what Gravity Forms can do.

Thanks Chris, do you know how typeform get around this?

I wish I did. I recommend contacting them or inspecting how they do it if you have access to Typeform.

1 Like