We have seen a few cases where users use iframe forms and want to direct visitors that filled in the form to a thank you page or PDF, video, etc.
The problem is that since the form is embedded on a landing page which is different from the parent one, the action happens only on the inner page where the form is.
To solve that, below are 2 Javascript tags we created. Insert in as an HTML element to your iframe pages or directly to the landing page template you use for iframes. Place it before the last </body> tag.
The first tag will perform the action on the parent page and the second tag will open it in a new tab.
Form Action on a Parent Page
1 2 3 4 5 6 7 8 |
<script> MktoForms2.whenReady(function (form){ form.onSuccess(function (values, url){ window.parent.location.assign(url); return false; }); }); </script> |
Form Action in a New Tab
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<script> MktoForms2.whenReady(function (form){ var newWin; form.onSubmit(function (){ newWin = window.open('about:blank', 'myWindow'); }); form.onSuccess(function (values, url){ newWin.location.replace(url); return false; }); }); </script> |