Data URI for CSV file in firefox not adding .csv extension

I have a "Download file" href defined in a javascript file as:

$("#downloadTag").html("<a href=data:text/csv;charset=utf-8," + encodeURIComponent(data) + ">Download</a>"); 

In chrome, it works as expected, that is, when I click on this download link, it gives the file name as "download.csv". However, in firefox, this puts some kind of gibberish name like "puzdb.part".

Can someone tell me what I am doing wrong?

thanks

Edit: Here is the jsfiddle daemon: http://jsfiddle.net/kLJz9/

Edit No. 2: I noticed that in windows it does not add the .csv extension for chrome, and the behavior for firefox is still the same (for example, the .part extension)

+6
source share
1 answer

In Chrome, you can specify a file name / extension by adding a download attribute to your anchor tag.

 <a href="URI" download="MyFile.csv">Download</a> 

This attribute only works in chrome v 14+ and without another browser.

I am also looking for a solution to this problem, but hope this helps.

EDIT:

the boot attribute should fix the problem that occurs on window machines and chrome.

+3
source

Source: https://habr.com/ru/post/912335/


All Articles