How to download file when clicking on the link?

In HTML5 <a> tag has a new "download" attribute.

Eg:
<a href="https://2.bp.blogspot.com/-XFFY1-JzHyU/WQqA0hH-WQI/AAAAAAAAAII/wj2IRZ6vDB0HSDVSpdPerVzqVv6grTShwCLcB/s1600/HeaderLogo.png" download>
In the above example the image will be downloaded when a user clicks on the hyperlink.

The 'download' attribute will work with .pdf, .txt, .html, etc. file extensions.

Final code and demo is here


Demo

No comments:

Post a Comment