Trigger download on form submit without opening new tab
Hello,
I've been asked to figure out how to trigger the download of a file upon clicking the submit button of a form while also displaying a thank you message ... all without opening a new tab. I've read through a number of posts asking for similar help but I'm still at a loss. (I don't even know if this is possible within Marketo.)
I don't know javascript well; this is the best I could come up with: (This, of course, opens up a new tab)
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 = '{{my.URL}}';
formEl.innerHTML = '<div style="width:280px;">{{my.Confirmation}}</div>';
return false;
});
});
Any help or guidance is greatly appreciated!