Skip to main content
Level 1
Mar 19, 2024 7:43 AM UTC
Solved

Marketo form - opening new tab on submission for external URL

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.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Mar 19, 2024 4:44 PM UTC
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; }); } });

2 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Mar 19, 2024 4:44 PM UTC
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; }); } });
Translate
Level 1
Mar 19, 2024 11:31 PM UTC

Thank you, Sandford!

 

Much appreciated.

Translate