Open New Tab After Form Submission for Downloads

SanfordWhiteman
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';    
    });
  
  });
shilohpaul
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. 

 

SanfordWhiteman
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.

shilohpaul
Level 2

Re: Open New Tab After Form Submission for Downloads

SanfordWhiteman
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.

shilohpaul
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.

SanfordWhiteman
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.

shilohpaul
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!

shilohpaul
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!

rperry04
Level 1

Re: Open New Tab After Form Submission for Downloads

Hi! Facing the same issue with this not working for Known Visitors -- any chance you could share the code to make that happen?

 

Thanks!