【发布时间】:2014-07-16 04:24:20
【问题描述】:
直到今天,它还在 Chrome 上运行以在客户端生成 KML 文件:
<script>
var kmlText = 'kml code here';
var link = document.createElement("a");
link.setAttribute("href", 'data:text/plain,' + kmlText);
link.setAttribute("download", "Export.kml");
link.innerHTML = "Download KML";
document.getElementById("myDIV").appendChild(link);
</script>
<html>
<div id="myDIV">Download</div>
</html>
从最近开始,该链接会强制下载,但不会接受 Chrome 上的文件名和扩展名,默认为“Download.txt”。 在 Firefox 上它可以正常工作,就像以前在 Chrome 上一样..
有人知道吗?
【问题讨论】:
标签: javascript html download href