x This domain is for sale. If you intrested, Please contact : webspeckle@gmail.com

How to download file when clicking on the link?

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

Eg:
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3_cJrsWP23faPEmIDCKvVH97xSZGJqUwdIWPQhad_fqgsZNbFjpCxZn9Uy4fjfV9MxCTNMLfw9s9MpUOczG8KNkR5_2pXO-vU2PwJ2EtuG_zhHiqvIyAgxiWgkyM_TqvzaCNLzqx4OCN_/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