Forms 2.0: iFrame follow-up script no longer works | Community
Skip to main content
Dan_Stevens_
Level 10
January 29, 2014
Question

Forms 2.0: iFrame follow-up script no longer works

  • January 29, 2014
  • 24 replies
  • 3341 views
Many of our Marketo forms are integrated into our website using iFrames.  Prior to Forms 2.0, we placed a small block of javascript code to enable the follow-up page to load in a full window (instead of within the iframe):

<script type="text/javascript" src="/js/public/jquery-latest.min.js"></script>
<script type="text/javascript">
    // set no conflict mode for jquery
  var $jQ = jQuery.noConflict();

  $jQ(document).ready(function(){
      // all form submits will open in a new window
    $jQ('.lpeRegForm').attr('target','_blank');
  });
</script>

I changed the bold line above to:
$jQ('.mktoForm').attr('target','_blank');
to reflect the new form <div> ID that's being used.  But this still isn't working.  Are there any others in this community that have deployed Forms 2.0 using iFrames and have gotten the follow-up page to open in a full window?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

24 replies

February 7, 2014
That's a shame. I had just submitted a ticket to try anyways. May I ask why you are using iframes still? We are because we like the ability to add design elements around our forms on the Marketo landing page and the embed doesn't allow us to do this.
Dan_Stevens_
Level 10
February 7, 2014
There are some limitations with using the embed code, such as the inability to pre-fill the form fields.  And if I recall, you can't do progressive profiling.  I could be wrong though.
February 8, 2014
Dan,

Jumping in here..Basically the form submit function has changed completely. The solution to make his work will require some new code. if you look on our developer site:

http://developers.marketo.com/documentation/websites/forms-2-0/

It's shows some new calls to make things happen, I've  requested our Pm and Eng look in to this feature and others that want to add custom scripts.

So far I've been testing with "form.onSuccess" , keep you posted...
I've been modifying this script not as an embed just the necessary parts in a html block :

//Add an onSuccess handler
  form.onSuccess(function(values, followUpUrl){
    //Take the lead to a different page on successful submit, ignoring the form's configured followUpUrl.
    location.href = "whatever.url.you.want/page.html";
    //return false to prevent the submission handler continuing with its own processing
    return false;
  });

Try
window.parent.location.href= "http://www.google.com";





 

February 10, 2014


Dan,

This is now resolved, I've updated your test page successfully.

Here's the code(place in a custom html block on the Marketo page) that should be used for iframing Mkto pages/forms .

 

<script> 

 

  function setupFormSuccess (){

 

    var form = MktoForms2.getForm(update with form id);

 

    if(!form){

 

      setTimeout(setupFormSuccess, 500);

 

    }else{

 

      form.onSuccess(function (values, url){

 

        window.top.location.href = url;

 

        return false;

 

      });

 

    }

 

  }

 

  setupFormSuccess();

 

</script>



 

Dan_Stevens_
Level 10
February 11, 2014
Don - this is wonderful news (and yes, it does work as intended now).  In fact, I felt the need to start a new community discussion so that it gets the visibility that it deserves.  Thanks so much!!! 

https://community.marketo.com/MarketoDiscussionDetail?id=90650000000PlzWAAS

P.S. - let me know if you'll be attending the Marketo Summit in April.  I owe you a couple of cold ones!!

February 11, 2014
Second round is on me! Thank you!
April 22, 2014
Just felt the need to thank Don for that code - was beating my head against my desk trying to figure it out using the code at https://community.marketo.com/MarketoResource?id=kA650000000GsRoCAK which doesn't work.
April 25, 2014
Don (and the rest of the team that worked on this) thank you so much! I have been pulling my hair out over this for the last week and am so excited to have finally found this post. Wonderful news and fantastic work.

I was in the same boat as John W--looking at some incorrect solutions. Could not be happier for this post.

Cheers!
June 2, 2014
Anyone have any issues with IE re this script?  I had heard that there was a problem with cookies on IE with 2.0 and wondering it this is it.

The code works fine on Firefox and Chrome, but will when I clear cache and start a test process on IE (fill out the form, back click and check or hit another link and return) my custom 2.0 welcome back message does not appear, just an unfilled form.

The question for me is whether the cookie is failing or the Welcome Back message but either way it is unfortunate this will not behave on IE like it is on other browsers
June 23, 2014
This is not working for me, but I suspect there's something I'm supposed to do with "update with form id", which is bold in the code, but I don't see anything here stating what I'm supposed to do. Does anyone know?