Skip to content

HTML5 download attribute not working when download external PDF file on Chrome

The code is very simple:

<a download href="http://www.pdf995.com/samples/pdf.pdf">Download</a>

I expect it to save the pdf file but it always open the file on the browser.

It works with other file type, just have problem with PDF file.

Answer

See the MDN documentation:

This attribute only works for same-origin URLs.

Presumably, the other file types, where you see it “working”, are ones where the default behaviour is to download the file.