Button onclick direct download

Hi webflow community,

I have a button that acts like a download button. I have a PDF I want the users to download when they click the button.

I uploaded the PDF to my server, but when the user clicks the button, his browser opens the PDF. I don’t want the user to be redirected outside the website, I don’t want to open a new tab either. I want that when you click the button, the file is directly downloaded and the users stays on the page.

How can I do this?

Thanks

2 Likes

Hello @justafish

Can you share your read only link?

Here’s how > https://university.webflow.com/article/sharing-your-sites-read-only-link

For direct download you need to add a custom link attribute (download), but the download attribute can’t be added from the settings panel.

Piter :webflow_heart:

Hey, I think I might have found a solution for this.
Its using Google Drive to grab the “Share Link”, but not to actually share. You grab the ID within the share link that google drive provides, and replace it with a url that simply downloads the file and never redirects the user outside the website.

2 Likes

Hmmm sounds interesting! I will try. Thanks for sharing :webflow_heart:

2 Likes

Perfect - just want my client wanted - this hack works perfectly.

Hey there! I’m trying to do a similar thing, but I want the user, once the download has begun, to redirect to another page. Any Chance you know how to do that?