So here’s a little simple snippet when you want to force a download when a file such as a PDF, .doc etc is clicked.
Normal actions will open the document in the either the same browser window, or in a new tab/window by using the usual target methods:
Open file in same window:
<a href="myfile.pdf" target="_self">Click to Download</a>
Open file in new window:
<a href="myfile.pdf" target="_blank">Click to Download</a>
However, if you want to force the file to download, by prompting a download pop-up box (to open or save), then all you need to do is add ‘download’ to the <a> link as seen below:
Force file download window:
<a href="myfile.pdf" download>Click to Download</a>
Voila! easy little tip. Hope this helps!