Open an iFramed Marketo Form's Follow Up Page in the parent page | Community
Skip to main content
December 11, 2014

Open an iFramed Marketo Form's Follow Up Page in the parent page

  • December 11, 2014
  • 3 replies
  • 2359 views

In some cases, you may want an iframed Marketo form to open in the parent page.

 

Note: Please ensure that you have access to an experienced JavaScript developer.

Marketo Technical Support is not set up to assist with troubleshooting JavaScript.


Is this article helpful ?

YesNo


FORMS 1.0
Add the following script to the src iframed page within a custom HTML block.


<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','_top');
   });
</script>

 


FORMS 2.0

 

<script >

MktoForms2.whenReady(function (form) {

    var form = MktoForms2.getForm(FORM_ID_HERE);

    form.onSuccess(function (values, followUpUrl)

    { window.top.location.href = followUpUrl; return false;

    });

});

</script>


To figure out what the form id is, the easiest way is to look at the embed code. It is the 4 digit number on the second line.

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

3 replies

pavel_plachky
Level 5
February 29, 2016

Thank you for this useful piece of code.

I would like to understand, why in the case of FORMS 2.0 you need the line

    var form = MktoForms2.getForm(FORM_ID_HERE);

What would happen if you omitted this line and used the form parameter, that is available to call-back function?

SanfordWhiteman
Level 10
March 1, 2016

You're right, Pavel.  There's no reason to retrieve the form via the form id if it's the same form you're already inside.  It's already a local var.

pavel_plachky
Level 5
March 1, 2016

Thanks, Sanford, I am glad you confirmed my understanding. We have users that want to add more forms on their site through iframes and it is easier for them to just clone a container page with a universal script rather than make them edit the script every time they add a new form.