I am trying to download some csv content via button click.
On click i have a javascript function that downloads the file using
window.location='data:application/webcsv;charset=utf8,' + encodeURIComponent(csvData);
But this file does not have any name and extension. How can i assign a file name using javascript?
You can’t specify filename or extension via the data uri. But if you use an
<a>element, you can use the[download]attribute:It’s not supported in every browser, but it’s a start.