Description: Users submit form > Open PDF in New Tab
#1. First, find Form Block ID.
In my example, it is: #block-86d852e7f10231beefe0
#2. Next, use this code to Code Injection > Footer
If code doesn’t work, you can comment below, message or send me an email.
Update: new code (07-03-2025)
<script>
window.addEventListener("load", (event) => {
const form = document.querySelector('#block-86d852e7f10231beefe0 form');
form.addEventListener('submit', function(e) {
e.preventDefault();
window.open("https://www.abideaway.com/s/Abideaway-Investment-Guide-2025-5.pdf", "_blank");
const formData = new FormData(form);
fetch(form.action, {
method: form.method,
body: formData,
headers: {
'Accept': 'application/json'
}
})
.then(response => {
if (response.ok) {
console.log('Form submitted successfully');
} else {
console.log('Form submission failed');
}
})
.catch(error => {
console.log('Error submitting form:', error);
});
});
});
</script>
#3. Remember to change Form ID + PDF URL