SOLVED

Re: open a new window after form submission

Go to solution
Anonymous
Not applicable

open a new window after form submission

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

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: open a new window after form submission

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>

View solution in original post

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: open a new window after form submission

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.

Anonymous
Not applicable

Re: open a new window after form submission

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
Level 10 - Community Moderator

Re: open a new window after form submission

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>

Anonymous
Not applicable

Re: open a new window after form submission

Thanks Sanford, this works great.

Anonymous
Not applicable

Re: open a new window after form submission

Hi! Thanks for the helpful information! I was wondering what code you need to put so the Thank you page opens in a new tab and not the parent window.

Thanks in advance!

SanfordWhiteman
Level 10 - Community Moderator

Re: open a new window after form submission

If you open a new post for this, I'll answer it there.  Better than adding to an old thread with a Correct answer.

Anonymous
Not applicable

Re: open a new window after form submission

Thanks for your answer. Here's the new thread: Open New Tab After Form Submission for Downloads