A 标签上的下载属性在 IE 中不起作用 [英] Download attribute on A tag not working in IE
问题描述
从以下代码中,我创建了一个下载文件的动态锚标记.此代码在 Chrome 中运行良好,但不适用于 IE.我怎样才能让它工作
<h3>示例标题</h3><button onclick="clicker()">点击我</button><script type="text/javascript">功能点击器(){var anchorTag = document.createElement('a');anchorTag.href = "http://cdn1.dailymirror.lk/media/images/finance.jpg";anchorTag.download = "下载";anchorTag.click();var element = document.getElementById('divContainer');element.appendChild(anchorTag);}
Internet Explorer 目前不支持 A
标签上的 Download
属性.
参见 http://caniuse.com/download 和 http://status.modern.ie/adownloadattribute;后者表示该功能在 IE12 中处于考虑中".
From the following code I'm creating a dynamic anchor tag which downloads a file. This code works well in Chrome but not in IE. How can I get this working
<div id="divContainer">
<h3>Sample title</h3>
</div>
<button onclick="clicker()">Click me</button>
<script type="text/javascript">
function clicker() {
var anchorTag = document.createElement('a');
anchorTag.href = "http://cdn1.dailymirror.lk/media/images/finance.jpg";
anchorTag.download = "download";
anchorTag.click();
var element = document.getElementById('divContainer');
element.appendChild(anchorTag);
}
</script>
Internet Explorer does not presently support the Download
attribute on A
tags.
See http://caniuse.com/download and http://status.modern.ie/adownloadattribute; the latter indicates that the feature is "Under consideration" for IE12.
这篇关于A 标签上的下载属性在 IE 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!