Answer the question
In order to leave comments, you need to log in
How to implement a link to download a file?
Good morning. You need to make a link to download the file. The problem is that it should work in ie 11 and this implementation, alas, is not suitable.
const download = filename, text) => {
let element = document.createElement('a');
element.setAttribute('href', 'somelink' + text);
element.setAttribute('download', filename);
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
Answer the question
In order to leave comments, you need to log in
Your sample code doesn't affect the download at all. IE may not like you doing a click() on an element. Perhaps opening a link in an iframe will work
IE (the most advanced browser!) does not support the Download attribute in "a" tags.
proof
here is an article in Russian about a possible solution
Where to dig
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question