cannot specify name of the download file using Javascript
csv, google-chrome, html, javascript, jquery
Solution
Nice work! This is a regression.
I just created another fiddle, and filed a Chrome bug.
If you're interested, star it in the bug tracker.
<a href="/" download="my-downloaded-file.html" target="_blank">Click here</a>
EDIT: It look like it depends on the URL. Absolute URLs work, as well as objects URLs (according to https://code.google.com/p/chromium/issues/detail?id=376197).
Problem
I am using Javascript to create a CSV file for user to download. Until May 22nd, Chrome still downloaded the file with the name I specified. However, today I found that the files downloaded are named "download" and do not have the extension .csv. This problem does not exist in Firefox! Here is a fiddle with sample Javascript: ``` var A = [['n','sqrt(n)']]; // initialize array of rows with header row as 1st item for(var j=1;j<10;++j){ A.push([j, Math.sqrt(j)]) } var csvRows = []; for(var i=0,l=A.length; i<l; ++i){ csvRows.push(A[i].join(',')); // unquoted CSV row } var csvString = csvRows.join("\n"); var a = document.createElement('a'); a.href = 'data:text/csv;charset=utf-8;base64,' + window.btoa(csvString); a.target = '_blank'; a.download = 'myFile.csv'; document.body.appendChild(a); a.click(); ```