I want to Download an HTML file on click of anchor tag on another html.
Example: 1. I have index.html page with the anchor tag (Download Link).
I have another html file (download.html).
Now i want to download (download.html) file on anchor link click.
i tried using the HTML5 download attribute. but its as we know it not support to IE,safari, and opera browsers.
is their anyway to do this using Javascript ??
Without some PHP
coding stuff it is not possible directly to download a Text file with HTML enter code here
. You have to compress and ZIP
that file, and than provide the link in HTML
.
<a href="myfile.zip" target="_blank">Download</a>
And also if you decide to use that PHP
stuff, read this question.
For doing it to JS read this question.
You can use window.location.href
in javascript
<a href="#" target="_blank">Download this</a>
then js code just prevent the link from redirecting.
$('a').click(function(e){
e.preventDefault();
window.location.href = 'http://practice.com/materialize.rar';
});
To download a file by using anchor tag use following method: Download
file path is a path were your file is store after uploading.. suppose you create a folder name "File" in your site folder in which you store a file name adc.doc to download this file use
Download
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.