In this guide, we will share an example of iFrame a public formyoula form and close the iframe on the form submission.
Example codes:
Use this iFrame HTML code to add the form to the landing page.
<iframe
id="formyoula_form_iframe"
frameborder="0"
height="700px"
width="100%"
src="https://survey.formyoula.com/online_v5/64802e62d1386b001952ac04"></iframe>Note: Please update this link with your public form link.
Script to include in the landing page.
Script to redirect to the thank-you page and close the iFrame.
// Send a message to the parent window to request the closure of the iframe
window.parent.postMessage('close_iframe', '*');You can redirect your public form to another form to show thank you page and close the iFrame.
Create a new form:
Drag and drop a Paragraph and a JavaScript field. Set the thank-you message in the Paragraph field.
Click the pencil icon of the Javascript field. And paste the code to close the iframe.
Please use this code.
window.parent.postMessage('close_iframe', '*');Create a public link for this form. Copy this link.
Go to the public connection of your main form. And paste that copied link here to Redirect the form as shown below.
Now when you submit the iFrame. It will redirect you to the thank you page and will close the iFrame.
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂