Force download through js or query

With the advent of HTML5 you could just use the new property download in the anchor tag.

The code will look something like

<a download="name_of_downloaded_file" href="https://stackoverflow.com/questions/5192917/path/to/the/download/file"> Clicking on this link will force download the file</a>

It works on firefox and chrome latest version. Should I mention that I didn’t check it in IE? 😛

Edited the download attribute after comment from sstur


https://caniuse.com/#feat=download

Leave a Comment