Form submission redirect not opening in new tab

I am trying to enable my freebie form to redirect to the actual PDF in the Google Drive folder in a new tab. I saw a few suggestions saying to make target=_blank in the custom attributes, but that’s not working for me. Any idea how to get this to work?

Read-only link

Hi Simone,

I think you would need to use the attribute ‘formtarget’ and not ‘target’ for this, however Webflow does not allow you to change this. It may break the form submission altogether, although I’m not sure. I’d recommend just redirecting users to a new page and offer the link there.

Hi @simonebreanna.

Add this JS code.

  1. Upload the PDF file to your Webflow project and note down its URL.
  2. In your Webflow project, go to the page where the form is located.
  3. In the JavaScript code editor, enter the following code:
var form = document.getElementById("your-form-id"); // Replace "your-form-id" with the ID of your form element
form.addEventListener("submit", function(event) {
  event.preventDefault(); // Prevent form submission
  
  // Open the PDF file in a new tab
  var pdfUrl = "https://www.example.com/path/to/your/file.pdf"; // Replace with the actual URL of your PDF file
  window.open(pdfUrl, "_blank");
  
  // Submit the form
  form.submit();
});

Make sure to replace "your-form-id" with the actual ID of your form element and "https://www.example.com/path/to/your/file.pdf" with the URL of your PDF file.

Save the changes to your Webflow project and publish it.

Now, when a user submits the form, the JavaScript code will intercept the form submission, open the PDF file in a new tab, and then submit the form as usual.