HTML <area> 标签的 download 属性

实例

使用 download 属性规定当用户单击超链接时将下载目标:

<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="info_about_the_sun.html" download="sun">
<area shape="circle" coords="90,58,3" alt="Mercury" href="merglobe.gif" download="mercury">
<area shape="circle" coords="124,58,8" alt="Venus" href="information_about_the_planet_venus.txt" download="venus">
</map>

亲自试一试

页面下方有更多 TIY 实例。

定义和用法

download 属性指定当用户单击超链接时将下载目标(在 href 属性中指定的文件)。

download 属性的可选值将是文件下载后的新名称。对允许值没有限制,浏览器会自动检测正确的文件扩展名并将其添加到文件中(.img、.pdf、.txt、.html 等)。

如果省略该值,则使用原始文件名。

浏览器支持

表格中的数字注明了完全支持该属性的首个浏览器版本。

属性ChromeInternet Explorer / EdgeFirefoxSafariOpera
download14.0*18.020.0*10.115.0

* Chrome 65+ 和 Firefox 仅支持同源下载链接。

语法

<area download="filename">

属性值

描述
filename可选。规定被下载文件的新文件名。

更多实例

实例

为 download 属性规定一个值,它将是下载文件的新文件名(sun.htm 而不是 information_about_the_sun.htm 等):

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" alt="Sun" href="info_about_the_sun.html" download="sun">
  <area shape="circle" coords="90,58,3" alt="Mercury" href="merglobe.gif" download="mercury">
  <area shape="circle" coords="124,58,8" alt="Venus" href="information_about_the_planet_venus.txt" download="venus">
</map>

亲自试一试