open a new window after form submission | Community
Skip to main content
June 26, 2015
Solved

open a new window after form submission

  • June 26, 2015
  • 1 reply
  • 4832 views

Hey everybody,

I am trying to figure out how to send the user to a new page when they submit a form. Currently I have to have the marketo landing page within an iFrame to embed it in my CMS page. Unfortunately, because the landing page is in an iFrame the redirect URL is also in the iFrame.

Can anybody suggest a way for me to be able to do this, either with or without having to embed my landing page within an iFrame.

Cheers,

Dean

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

In the landing page, add an HTML block.  In it, put

<script>

MktoForms2.whenReady(function(form) {

  form.onSuccess(function(vals, thankYouURL) {

    window.parent.location = thankYouURL;

    return false;

  })

})

</script>

1 reply

SanfordWhiteman
New Participant
June 26, 2015

Your question seems to use the terms "new page" and "new window" interchangeably, but the tasks are quite different.

If you do mean a new top-level page opened in the same browser tab, then use the onSuccess handler in your IFRAMEd form:

form.onSuccess(function(vals,thankYouURL){

    window.parent.location = thankYouURL;

    return false;

})

Or you could switch to embedding the form directly in the CMS page using the embed code, in which case there would no longer be a problem with the redirect.

If you mean ​a new tab/window opened on form success, ​then let me know, because that is more complex.

June 29, 2015

Hi Sanford, Thanks for your reply.

I am new to this whole thing and don't have a background in HTML coding. Could you explain where I should be putting the onSuccess handler. Below is the code that I am using to embed the landing page that contains my form into my CMS page.

<div><iframe height="600" return="" scrolling="no" src="LANDING PAGE URL" style="overflow: hidden;" width="640"></iframe></div>

Cheers,

Dean

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
June 29, 2015

In the landing page, add an HTML block.  In it, put

<script>

MktoForms2.whenReady(function(form) {

  form.onSuccess(function(vals, thankYouURL) {

    window.parent.location = thankYouURL;

    return false;

  })

})

</script>