Trouble getting an external URL to display in Thank You Page after a form submit

Kerry_Productio
Level 2

I'm having trouble getting an external URL to display in Thank You Page after a form submit.  The form is currently iframed in our website.  When you hit submit on the form, right now it's just blank.  I think it's just Staying On The Same Page, which was our initial setting on the form for the Thank You page. 

I've approved the form template and the landing page after making the change, so that's not the issue.

Any ideas?

Thanks in advance!

Tags (1)
17 REPLIES 17
Kerry_Productio
Level 2

Thanks for all your input.  I'm still very green with Marketo (taking Foundational Training next week) so I didn't realize that I had to change the redirect on both the Form Template AND the Landing Page that the form was on. I was only changing it on the Form Template. 

Grégoire_Miche2
Level 10

Hi Kerry,

In fact you do not need to do both.

  1. either you set the redirect you want at the form level and, at the landing page level, you set it to "Form defined"
  2. Or you just set the redirect at landing page level and the form level setting is not relevant

-Greg

Kerry_Productio
Level 2

So originally we were trying to get to display "Thank You...." in the frame of the iFrame but we've run into SSL certificate issues where it's not set up in our Marketo instance but it is set up on our website so it's calling https when the page is still http.  So I was trying to find a work around in the meantime until we can get our certificate set up. 

I set the external URL in the form itself, not the landing page.

Grégoire_Miche2
Level 10

Hi Kerry,

As your web site in on https, it is strongly recommended that you do the same for your Marketo instance, for multiple reasons. And one of them is that it will solve your problem

-Greg

Kerry_Productio
Level 2

Yes we implementing https on our Marketo instance.  It's in process.  Like I said, I was just looking for a temporary solution because right now our Contact Sales form gives you a blank page within the iframe when you submit.  Not ideal. 

SanfordWhiteman
Level 10 - Community Moderator

Do these two domains share a parent domain (as pages.example.com and www.example.com share example.com)?

If so, this is quite easy.

In the main document:

<script>

     try { document.domain = 'example.com' } catch(e){};

</script>

On your Marketo LP:

<script>

MktoForms2.whenReady(function(form){

    form.onSuccess(function(vals,tyURL){

        try { document.domain = 'example.com' } catch(e){};

        self.parent.document.location = tyURL;

        return false;

    });

});

</script>

Anonymous
Not applicable

This worked perfect! Thank you.

Grégoire_Miche2
Level 10

Hi Kerry,

You could use a Form 2.0 api JS code to hide the form and replace the follow-up page with a simple message.

Look here: Forms 2.0 » Marketo Developers The first example is exactly about this:

MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {

   // Add an onSuccess handler

  form.onSuccess(function(values, followUpUrl) {

   // Get the form's jQuery element and hide it

  form.getFormElem().hide();

   // Return false to prevent the submission handler from taking the lead to the follow up url

   return false;

   });

});

-Greg

Robb_Barrett
Level 10

this works fine for me from an iFrame, but we open a new tab I believe.

form.onSuccess(function() {

window.open(LinkURL);

return false;

      });

Robb Barrett
SanfordWhiteman
Level 10 - Community Moderator

window.open will be blocked as a popup unless you create the window in ​onSubmit.

Robb_Barrett
Level 10

Really? Hasn't for me yet.

Robb Barrett
SanfordWhiteman
Level 10 - Community Moderator

What's a sample URL?  This is a known limitation when window.open is not in response to a user-initiated event (onSuccess is not in response to user activity, but onSubmit is).

Anonymous
Not applicable

I am having this exact issue. So if I add this (below) it will work? Do I add it to the site or my LP that is in the iframe?

form.onSubmit(function() {

window.open(LinkURL);

return false;

      })

SanfordWhiteman
Level 10 - Community Moderator

You should use the code I posted above which touches both pages and can deal with problems in some environments (that is, if your IFRAMEs share the same registered domain but the IFRAME has been embedded in sandboxed mode, it will still work).

The code you posted cannot bust out of an IFRAME, ever.  The page will remain framed.

Grégoire_Miche2
Level 10

Hi Kerry,

Since the form is in an iframe, the thank you page will only replace the content of the iframe. It will not drive the whole page to the other external URL.

How have you set the external URL? In the form ? in the Landing page ?

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Since the form is in an iframe, the thank you page will only replace the content of the iframe. It will not drive the whole page to the other external URL.

If you don't use onSuccess, yes. that's true.  But using the custom event, it's quite possible to replace the top-level document, either if the domains share a parent and/or if you can add a line of JS to the top-level document.

SanfordWhiteman
Level 10 - Community Moderator

Are you attempting to change the URL of the top-level document, or the URL of the document in the IFRAME? Post the URL to the page, please.