小编典典

下载标签上的属性在IE中不起作用

html

从下面的代码中,我正在创建一个动态锚标记,用于下载文件。此代码在Chrome中效果很好,但在IE中效果不佳。我该如何工作

<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>

阅读 293

收藏
2020-05-10

共1个答案

小编典典

Internet Explorer当前不支持标签Download上的属性A

参见http://caniuse.com/downloadhttp://status.modern.ie/adownloadattribute;后者表示该功能是IE12的“正在考虑中”。

2020-05-10