Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML download 属性


定义和用法

download 属性指定当用户点击超链接时将下载目标。

此属性仅在设置了 href 属性时使用。

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

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


适用于

download 属性可以在以下元素上使用

元素 属性
<a> download
<area> download

示例

示例

点击链接时下载文件(而不是导航到文件)

<a href="/images/myw3schoolsimage.jpg" download>
亲自尝试 »

区域示例

一个具有可点击区域的图像地图,点击后将被下载

<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="info_about_the_sun.htm" 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>
亲自尝试 »

浏览器支持

download 属性对每个元素具有以下浏览器支持

元素
a 14.0 13.0 20.0 不支持 15.0
area 14.0 不支持 20.0 不支持 15.0

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.