代码示例:(标识:htmldom_anchor_download_1)
<!DOCTYPE html>
<html>
<body>

<h1>Anchor 对象</h1>

<h2>download 属性</h2>

<p>如果用户单击有 download 属性的图像,则会下载该图像:</p>

<a id="myAnchor" href="/logo.png" download="logo">
<img src="/logo.png" alt="(www.sou-xun.com)" width="180" height="167">
</a>

<p>download 属性的值是:</p>
<p id="demo"></p>

<p>Internet Explorer 不支持 download 属性。</p>

<script>
let text = document.getElementById("myAnchor").download;
document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>
运行结果: