Not work html5 a tag href download attr.

Please check the sources : 

<a href="" download="test.png">Download Image</a>

I added the download option to a tag using JavaScript.

However, the download window will not appear and will be moved to the href address.

How do I force url to download from the client side?

I respect all the developers. Thank you for reading this article.


For me it works fine in Chrome 70 for me, but you could try adding  target="_blank" to the link as a fallback.

I got the information and tested it from my side using this applet:

from this page:

1 Like

I don’t understand.

try this code 

<a href="" download>
  <img src="" alt="W3Schools" width="104" height="142">

Works fine on my PC (Chrome 70). On an iPad, for example, this won’t work because iOS can’t “download” things like that. That is why I suggested adding target=“_blank” to the a  element. For browsers that support downloading, nothing will change. For browsers that don’t, the image wil, open in a new tab so users can manually download the file.

a [download] can no longer download resources from a different origin. See how I fixed that here