HTML5: Force href to external file to download
Posted: Thu Sep 12, 2019 3:25 am
Hi all,
A few of my HTML5 pages have hyperlinks to files (plain text, but with a custom file type). If the user clicks these links in their browser, I need to force these links to download rather than opening directly in the browser.
HTML5 supports the "download" attribute, as in the following example:
But when I try to include this in my topic files, the Text editor gives me the warning:
I can't seem to find a way around it. The clumsy way is to tell the user to right-click the link, but I need to make this idiot-proof.
So, has anyone else successfully implemented the download attribute?
A few of my HTML5 pages have hyperlinks to files (plain text, but with a custom file type). If the user clicks these links in their browser, I need to force these links to download rather than opening directly in the browser.
HTML5 supports the "download" attribute, as in the following example:
Code: Select all
<a href="path/to/file" download>Click here to download</a>
Code: Select all
'>' is an unexpected token. The expected token is '='.
So, has anyone else successfully implemented the download attribute?