0
I have a page with several PDF files and when I click on some it opens a modal with a form to fill, after the confirmation of sending the file opens twice in a new tab, I would need that it does not open 2 times, but yes that it downloads automatically.
var fileLink, modalForm;
var showModal = true;
jQuery(function() {
// Modal
modalForm = jQuery('#modal');
jQuery('.post-attachments')
.find('a')
.click(function() {
fileLink = jQuery(this);
modalForm.modal();
return false;
})
});
document.addEventListener( 'wpcf7mailsent', function( event ) {
downloadFile()
}, false );
function downloadFile() {
showModal = false;
window.open(fileLink.attr('href'));
modalForm.modal('hide');
}
Is there any way to do it directly in js? Without having to add the download attribute to the tag.
– Natanael Oliveira