Gue*_*est 2 html javascript csv file filereader
有没有办法使用txtHTML5将内容保存为文件?
它不应该是真正的 csv。csv file extension
像这样的东西{type:'text/csv'};在哪里行不通{type:'text/plain'};。
标签a的新download属性可以为您带来优势。 更多信息。
概念证明:
<!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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2774 次 |
| 最近记录: |