Reputation: 426
I have a blog here where I have used an anchor tag (<a>
) with the download
attribute for an HTML file:
<a href="http://www.idevelopweb.site/newsletters/welcome-simple/welcome-simple.html" download>Download it here <i class="fa fa-download" aria-hidden="true"></i></a>
Screenshot:
Expected: when the user clicks, it should open the dialogue box to download the file.
However, it navigates to the file. AFAIK, it was working earlier. Not sure what happened, or am I missing something? As per this w3schools example, ".html" file is allowed.
Any help would be much appreciated without using JavaScript.
EDIT: This blog is in a subdomain (http://blog.idevelopweb.site/) and I'm calling the HTML file which is in the root directory (http://www.idevelopweb.site/) so I have used an absolute path.
Upvotes: 5
Views: 13125
Reputation: 515
In your Code
<a href="http://www.idevelopweb.site/newsletters/welcome-simple/welcome-simple.html" download>Download it here <i class="fa fa-download" aria-hidden="true"></i></a>
The href
contain link of the webpage instead of the data , image or file which nedded to be downloaded. The webpage cant be downloaded using download attribute of anchor tag.Thus it should be in format:
<a href= "--link of image or file to be downloaded--" download > Download </a>
For example:
<a href="/images/myw3schoolsimage.jpg" download> Download </a>
This download the myw3schoolsimage.jpg
image
Upvotes: 0
Reputation: 127
Download file when clicking on the link (instead of navigating to the file):
<a href="link" download="logo">
Note: The download attribute is not supported in Edge version 12, IE, Safari 10 (and earlier), or Opera version 12 (and earlier)
Upvotes: 1
Reputation: 1613
I may direct you to here.
Your problem is the same origin policy of the download attribute. So either use the same url or relative path.
Upvotes: 6