简体   繁体   English

html5 href下载属性问题

[英]html5 href download attribute issue

Until today this was working on Chrome to generate a KML file client-side: 直到今天,这是在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>

Since recently the link would force a download but wouldn't accept the filename and extension on Chrome, defaulting to 'Download.txt'.. On Firefox it is working properly, as it was before on Chrome, too.. 从最近链接将强制下载,但不接受Chrome上的文件名和扩展名,默认为'Download.txt'..在Firefox上它正常工作,就像之前在Chrome上一样..

Here's a fiddle 这是一个小提琴

Does someone have a clue? 有人有线索吗?

It looks like a bug in chrome. 它看起来像铬中的一个bug。 I can't reproduce it on my desktop. 我无法在桌面上重现它。

You should file a bug here: https://code.google.com/p/chromium/issues/list 您应该在此处提交错误: https//code.google.com/p/chromium/issues/list

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM