Reputation: 647
I had read the following:
How to trigger a file download when clicking an html <a> tag or javascript in a modern browser
How to trigger a file download when clicking an HTML button or JavaScript
For me isn't working.
I have a link to a file https://childrensradiofoundation.org/wp-content/uploads/2020/09/2020_COVID19-_RemoteOutreach_Campaigns_English_D3.pdf
and I want to download the file:
<a class="nav-link" href="https://childrensradiofoundation.org/wp-content/uploads/2020/09/2020_COVID19-_RemoteOutreach_Campaigns_English_D3.pdf" download>Download</a>
The code above open a new tab with the link and doesn't download the file.
Any suggestions with simple JavaScript if plain HTML not working?
I don't want a button (the link is in Nav Bar).
LATER EDIT: As @Lundstromski suggest bellow, there is no way to do that.
Upvotes: 1
Views: 1443
Reputation: 1247
The link works as intended for me with a dummy file.
<a class="nav-link" href="https://file-examples-com.github.io/uploads/2017/02/file-sample_500kB.docx" download>Download</a>
Upvotes: 1