Open New Tab After Form Submission for Downloads

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

It's same code as above, except you're using the form-level followUpUrl as is instead of overriding it in the code. Thus change:

form.onSuccess(function(vals,followUpUrl) { 

  thankYouWindow.document.location = 'http.example.html';      

});

to this:

form.onSuccess(function(vals,followUpUrl) { 

  thankYouWindow.document.location = followUpUrl;      

  return false;

});

You have to put the code block after the forms library is loaded. Thus in these cases the safest place to put the <script> is actually right before the closing <body> tag.

Highlighted
Anonymous
Not applicable

Re: Open New Tab After Form Submission for Downloads

Hi Sanford,

Thank you for the quick reply. Sorry for my ignorance (and the fact, I am

not a developer), but what code exactly that you mention above? Here is the

landing page url: http://lp.zilliant.com/AI_Delivers.html

The form lives on this LP, and since I am using a template, where exactly

am I placing the code? I don't have access to edit in the HTML unless I

update the main template code. Is this where you suggest this code be

placed? And if I do update in the main template, will that carry over to

the new LP I created using the main template? There is a Custom head HTML

section in the newly created LP settings.

Thank you,

Kevin

On Mon, Mar 6, 2017 at 2:16 PM, Sanford Whiteman <

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

what code exactly that you mention above?

The code in the post right above yours in this thread.

The form lives on this LP, and since I am using a template, where exactly

am I placing the code? I don't have access to edit in the HTML unless I

update the main template code. Is this where you suggest this code be

placed? And if I do update in the main template, will that carry over to

the new LP I created using the main template? There is a Custom head HTML

section in the newly created LP settings.

You can put the code in the template, before the closing <BODY> tag. Note it will (by definition) apply to all LPs based on this template, after you reapprove them.

Custom <head> is the opposite of <body>.  You can put it in the <head> but then you need slightly more complex code.

Highlighted
Anonymous
Not applicable

Re: Open New Tab After Form Submission for Downloads

Okay that makes sense. Do I just replace the form info in the below code?

MktoForms2.loadForm("//app-sj11.marketo.com", "433-ODK-889", 1133);

And do I need this code as well even though it is not a lightbox?

MktoForms2.lightbox(form).show();

On Mon, Mar 6, 2017 at 2:36 PM, Sanford Whiteman <

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

You don't replace the default embed code -- the MktoForms2.whenReady() call is in addition to the MktoForms2.loadForm() call.

Right, if you're not using a lightbox, you don't need the lightbox line.

Highlighted
Anonymous
Not applicable

Re: Open New Tab After Form Submission for Downloads

I meant do I replace the following "//app-sj11.marketo.com", "433-ODK-889",

1133 in the *MktoForms2.loadForm section. It looks like that form info

pertains to the other persons form ID, correct.*

*Sorry for any confusion or to be a pain, but I am just trying to

understand this so I don't create any errors. I do appreciate your help.*

Kevin

On Mon, Mar 6, 2017 at 2:52 PM, Sanford Whiteman <

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

Oh, of course you use your own embed code with your own Munchkin ID et al.

Highlighted
Anonymous
Not applicable

Re: Open New Tab After Form Submission for Downloads

I made the changes and that seemed to work, however, that code has added another form to the LP. Check it out: Landing Page 

I tried to clear the form assignment in the new landing page thinking that with the addition of the code, it would have the form appear, but that didn't work. So I added it back in and now there are two forms. Any suggestions to remove the top form which is the one that opens in the same window.

Thank you,

Kevin

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

You don't need to run loadForm() again. When you embed a named form element, loadForm() is inserted for you, so you only need to add the form behaviors (whenReady).

Anonymous
Not applicable

Re: Open New Tab After Form Submission for Downloads

Okay that worked, however, when I clicked Download Now, it opens in a new window/tab but the PDF does not appear (and I have it set for external URL). It opens to our sites homepage. I am trying to get the PDF to open in a new window/tab.

And just to be clear, this is the line of code that I removed: 

MktoForms2.loadForm("//app-ab17.marketo.com", "004-KXL-870", 1058);

Thank you again for your help, Sanford.

Kevin