Streaming live at 10am (PST)

Custom <a> attribute 'download'


#1

Hi!

I have a link block which gets its URL from a CMS record. The URL points to a PDF. The link works and opens the PDF in the browser. So far, so good. But:

I would like to force the download of the PDF using the HTML5 download attribute in the link, like
<a href="file.pdf" download>Click here</a>
So I've tried using the custom link attribute in the link block settings in the designer. Unfortunately an attribute named "download" is not accepted saying "this is a reserved name".

Any ideas how to add a download attribute to an a-element in Webflow?

BR,
Norbert


PDF File opens in browser and not as a download
#2

We should be able to do it with custom attributes.

The correct syntax for download is:

<a href="path/file.jpg" download="Picture of an elephant">Download the picture of an elephant</a>

So it's exactly a custom attribute. But the Download name is reserved by Webflow.

http://www.w3schools.com/tags/att_a_download.asp

So, you can use a custom code element to address that. It works with CMS. As soon as you have a custom code element inside a dynamic list, you can inject some of you CMS data into the code. Here you'd possibly need to retrieve the URL of the file and the description of the download.

Select the URL, then the description, and click +Add field on the top right corner to link that portion of code to your database.


How to create PDF direct download link – with no click/button required?
#3

Where is your pdf hosted at?

See this if you are using the popular file hosting sites: https://milanaryal.com/direct-linking-to-your-files-on-dropbox-google-drive-and-onedrive/


#4

Hi Vincent,
thanks for the hint. I see custom code is a workaround.
However, it's a pity that Webflow blocks HTML standard attributes.


#5

The PDFs are hosted at one of our subdomains - standard webhosting.


#6

There's maybe a good reason but I don't know about it :slight_smile: Click attribute and a lot of cool others are blocked too.

@cyberdave is there any disclosable info about the reserved terms?


#7

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.