Is there a way to save content as a txt
file with a csv file extension
using HTML5 ?
It shouldn\'t be a real csv.
Some
The a
tag's new download
property can work to your advantage here. More information.
Proof of concept:
<!doctype html>
<html>
<head>
<script type="text/javascript">
function save() {
var a = document.createElement('a');
with (a) {
href='data:text/csv;base64,' + btoa(document.getElementById('csv').value);
download='csvfile.csv';
}
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
</script>
</head>
<body>
<textarea id="csv"></textarea><button onclick="save()">Save</button>
</body>
</html>