Embedded landing form redirection

Katie_Owens1
Level 2

Embedded landing form redirection

Hello,
we have a marketo landing with a form and we're embedding it with an iFrame.

We want the parent page (outside the iFrame) to be redirected once the form is submitted and we're using this script inside the marketo landing:

<script>
  function setupFormSuccess (){
    var formID = $('[name="formid"]').val();
    var form = MktoForms2.getForm(formID);
     if(!form){
 setTimeout(setupFormSuccess, 500);
     }else{
       form.onSuccess(function (values, url){
         window.top.location.href = url;
        return false;
       });
    }
  }
  setupFormSuccess();


</script>
 
The problem is tha it is working correctly on chrome, but on firefox it doesn't always work and we can't find the error. Is there a better way to do this?


 

Tags (1)
4 REPLIES 4
Anonymous
Not applicable

Re: Embedded landing form redirection

Is there a reason that you aren't setting the forms exit page to the page you want the outer page directed to?
Katie_Owens1
Level 2

Re: Embedded landing form redirection

We do have set the forms exit page to the page we want, but the Marketo landing is inside an iFrame and we don't want to load the "thankyou" page inside the iframe but on the parent container!

 

Anonymous
Not applicable

Re: Embedded landing form redirection

I have this same exact issue.  Has anyone found a workaround/solution for this? 

SanfordWhiteman
Level 10 - Community Moderator

Re: Embedded landing form redirection

The code above is broken.  The seemingly erratic behavior in FF is probably because of the unnecessary setTimeout.

MktoForms2.whenReady(function(form) {

  form.onSuccess(function(vals,tyURL){

     window.top.location.href = tyURL;

     return false;

  });

});