Open New Tab After Form Submission for Downloads

Tim_Marcacci
Level 2

Re: Open New Tab After Form Submission for Downloads

Nevermind. I was able to find that I can use <span> tags to style accordingly.

Jon_Wright
Level 4

Re: Open New Tab After Form Submission for Downloads

Hi Sanford Whiteman​ - when I change the url in the codepen example to a PDF it doesn't load, it opens a new tab with the PDF url but there is just a white screen. This is only in Chrome. Seems to work fine in FF. Any ideas?

MktoForms2.loadForm("//app-sj01.marketo.com", "410-XOR-673", 333);

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;

});

});

SanfordWhiteman
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

Have you turned off the Chrome viewer or have some other plugin interfering? The easy test is to open a new tab manually and put that PDF URL in the location bar. The behavior should be exactly the same as when the form opens the tab.

Jon_Wright
Level 4

Re: Open New Tab After Form Submission for Downloads

Thanks Sanford. I've checked and:

'Download PDF files instead of automatically opening them in Chrome' is Off

The PDF loads if I manually put it into a new tab

PDF doesn't load if I refresh the page the JS opened

Although the issue only seems to be occurring in CodePen on Chrome - running Version 73.0.3683.75 (Official Build) (64-bit). It does work if I add it to a Marketo LP, which I guess is good enough for me. But strange it's not working in CodePen.

SanfordWhiteman
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

Are you running it from the debug CodePen (change /run/ in the UTL to /debug/)?

SanfordWhiteman
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

See video of CodePen demo on Chrome 73 x64/Windows 10: CrossBrowserTesting Video Recording

Jon_Wright
Level 4

Re: Open New Tab After Form Submission for Downloads

Thanks for the tips, Sanford. But still doesn't seem to be working, but I'm guessing it must be something local to my machine: Video recording

SanfordWhiteman
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

How could it be local to your machine if it's happening on CodePen using the CBT lab?

Jon_Wright
Level 4

Re: Open New Tab After Form Submission for Downloads

I thought maybe one of my browser settings? Do you think it's a CodePen setting?

SanfordWhiteman
Level 10 - Community Moderator

Re: Open New Tab After Form Submission for Downloads

Test the "debug" mode on CodePen, not "full": https://codepen.io/jwright_tmf/debug/oVPVWE