English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
download属性指定当用户单击超链接时将下载目标。仅当设置了href属性时,才使用此属性。该属性的值将是下载文件的名称。对允许的值没有限制,浏览器将自动检测正确的文件扩展名并将其添加到文件(.img,.pdf,.txt,.html等)中。如果省略该值,则使用原始文件名。
一个带有可点击下载区域的图片:
<!DOCTYPE html> <html> <title>HTML:<area> download 属性 - 基础教程网 oldtoolbag.com</title> <body> <img src="planets.gif" width="145"height="126"alt="Planets" usemap="#planetmap"> <map name="planetmap"> <area shape="rect" coords="0,0,82,126" alt="Sun" href="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> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
Currently, only Firefox and Chrome support the download attribute.
The download attribute specifies the target that will be downloaded when the user clicks on the hyperlink.
This attribute is used only when the href attribute is set.
The value of this attribute will be the name of the downloaded file. There are no restrictions on the allowed values, and the browser will automatically detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.).
If the value is omitted, the original filename will be used.
The download attribute is an HTML5new attributes of the <area> tag in HTML.
<area download="filename">
Value | Description |
---|---|
filename | Specify the file name. |