Open New Tab After Form Submission for Downloads

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

  MktoForms2.loadForm("//app-sj11.marketo.com", "433-ODK-889", 1133);
  MktoForms2.whenReady(function(form) {
  
    var thankYouWindow;
  
    MktoForms2.lightbox(form).show();
  
    form.onSubmit(function(form) {
      form.addHiddenFields({
        previousURI : document.location.href      
      });    

      thankYouWindow = window.open('');
    });

    form.onSuccess(function(vals,followUpUrl) {
      thankYouWindow.document.location = 'http.example.html';    
    });
  
  });
Highlighted
Level 2

Re: Open New Tab After Form Submission for Downloads

Thank you!

 

I'm not able to get the download button to work when onSuccess function is in there. I've tried deleting the onSuccess function, and then the button does work to send them to the PDF, but it doesn't open in a new tab. I also tried keeping the onSuccess function in there but using the previousURI variable rather than a string with the URL, but it's the same result as the URL string.

 

The lightbox also doesn't work for our site so I removed that - not sure if that could be causing the issue. 

 

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

You need to provide the URL of the page so I can see what else is going on.

Highlighted
Level 2

Re: Open New Tab After Form Submission for Downloads

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

Right now, the PDF opens in a new window onSuccess as expected, when the form is visited anonymously. 

 

I think what else is confusing you is you're using Known Visitor HTML. In that mode, the onSubmit doesn't fire, so you never create the new popup window, as you can see in the browser console.

Highlighted
Level 2

Re: Open New Tab After Form Submission for Downloads

I see thank you! Is there a way to have it also open in a new tab for a known visitor as well? Right now the download button is not working at all for Known Visitor.

Highlighted
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

I see thank you! Is there a way to have it also open in a new tab for a known visitor as well? Right now the download button is not working at all for Known Visitor.


There is, sorry but I'm too busy to put the code together right now. You might check back in a week.

Highlighted
Level 2

Re: Open New Tab After Form Submission for Downloads

No worries! Whenever you have time is great - I really appreciate the help! I know it's a weird mix of scenarios.

 

Edit: @SanfordWhiteman any luck? Thank you!

Highlighted
Level 2

Re: Open New Tab After Form Submission for Downloads

Hi @SanfordWhiteman!

 

We still haven't been able to figure this out. Was hoping you had a chance to look at it. We'd really appreciate any help!

 

Thanks!

Highlighted
Anonymous
Not applicable

Re: Open New Tab After Form Submission for Downloads

Hi Sanford,

I also have added a form to a marketo landing page, which is being used off a template they created for us. When I attached the PDF url for the form submission (as external URL), it opens in the same window. I prefer the document open in either a new window/tab. How do you suggest I go about this? And if it's adding some code to the landing page, since it is a template, would that code be added in the "Custom HEAD HTML" section?

Thank you,

Kevin