我想在我的wordpress网站上下载pdf之前添加弹出窗口。我尝试添加联系表单7事件侦听器,但无法正常工作。有什么想法吗?
<p class="margin-xs-top20"><?php
if( get_field('download') ): ?>
<button data-toggle="modal" data-target="#myModal" type="file" class="btn btn-default btn-lg btn-primary btn-huge">download publication
<script>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '4265' == event.detail.contactFormId ) { // Sends sumissions on form 4265 to the first thank you page
var pdfLink = '[DOMAIN]/wp/wp-content/uploads/2018/06/file.pdf';
} else if ( '4266' == event.detail.contactFormId ) { // Sends submissions on form 1070 to the second thank you page
var pdfLink = '[DOMAIN]/wp/wp-content/uploads/2018/06/file2.pdf';
}
else {
//do nothing
}
jQuery.get(pdfLink, (data) ->
window.location.href = jQuery(this).attr('href');
)
}, false );
</script>
</script></button>
<?php endif; ?></p>