Have you ever wanted to have a link to a resource, such as a PDF file, and have that resource be automatically downloaded when the link is clicked? All you need to do is add a download
attribute to your link HTML.
<a href="/resources/newsletter.pdf" download>Newsletter</a>
But wait, the download
attribute isn’t supported across all the current browsers! It won’t work in Internet Explorer or Safari. So, the next best thing is to make sure that the link opens in a new tab when it can’t be downloaded.
<a href="/resources/newsletter.pdf" target="_blank" download>Newsletter</a>
Since you probably can’t count on your content editors to know HTML, much less reliably set these attributes on every link they create, the best thing would be to add this jQuery code snippet to your site:
Now you have a simple, reliable way to handle download links on your site. If you need to force download other file types, just add some code for the file extensions of your choice.