rndme / download

file downloading using client-side javascript
MIT License
2.28k stars 417 forks source link

Chrome don't support download attribute in anchor tag #104

Closed lazaro770407 closed 1 year ago

lazaro770407 commented 3 years ago

Chrome don't support download attribute in anchor tag when yo click this link chrome force to download file and in my case need that open file and don't work if remove download attribute work fine.

function saver(url, winMode) { if ('download' in anchor) { //html5 A[download] anchor.href = url; anchor.setAttribute("download", fileName); //THIS LINE anchor.className = "download-js-link"; anchor.innerHTML = "downloading..."; anchor.style.display = "none"; document.body.appendChild(anchor); setTimeout(function () { anchor.click(); document.body.removeChild(anchor); if (winMode === true) {setTimeout(function () { self.URL.revokeObjectURL(anchor.href);}, 250);} }, 66); return true; }

hugobernardoni commented 2 years ago

I have the same problem. Can you help?

rndme commented 1 year ago

This is probably a result of the Content-Disposition header sent by the href's URL response. You can (if using CORS/SO) fatch the response to a blob, the URL.createObjectURL(theBlob) to get a url w/o http behavior (specifically UA downloading).

I don't see how this relates to download.js though, so closing.