Marketo form - opening new tab on submission for external URL | Community
Skip to main content
New Participant
March 19, 2024
Solved

Marketo form - opening new tab on submission for external URL

  • March 19, 2024
  • 1 reply
  • 2070 views

Regarding the code below - is there a way to make this work only for a specific form ID?

 

I tried using if (formId == xxxx) in there but couldn't get it working.

Any help would be appreciated.

 

 

MktoForms2.whenReady(function(form) { var formEl = form.getFormElem()[0], thankYouWindow; form.onSubmit(function(form) { thankYouWindow = window.open(''); }); form.onSuccess(function(vals, thankYouURL) { thankYouWindow.document.location = 'https://info.tmforum.org/rs/021-WLD-815/images/dtw-2019-event-brochure.pdf'; formEl.innerHTML = 'Thank you! Your asset has opened or downloaded in a new window.'; return false; }); });

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman
MktoForms2.whenReady(function(form) { const formEl = form.getFormElem()[0], formId = form.getId(); const newTabFormIds = [1234,5678]; if( newTabFormIds.includes(formId) ) { let thankYouWindow; form.onSubmit(function(form) { thankYouWindow = window.open(''); }); form.onSuccess(function(vals, thankYouURL) { thankYouWindow.document.location = 'https://info.tmforum.org/rs/021-WLD-815/images/dtw-2019-event-brochure.pdf'; formEl.innerHTML = 'Thank you! Your asset has opened or downloaded in a new window.'; return false; }); } });

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
March 19, 2024
MktoForms2.whenReady(function(form) { const formEl = form.getFormElem()[0], formId = form.getId(); const newTabFormIds = [1234,5678]; if( newTabFormIds.includes(formId) ) { let thankYouWindow; form.onSubmit(function(form) { thankYouWindow = window.open(''); }); form.onSuccess(function(vals, thankYouURL) { thankYouWindow.document.location = 'https://info.tmforum.org/rs/021-WLD-815/images/dtw-2019-event-brochure.pdf'; formEl.innerHTML = 'Thank you! Your asset has opened or downloaded in a new window.'; return false; }); } });
New Participant
March 19, 2024

Thank you, Sandford!

 

Much appreciated.