download屬性指定當(dāng)用戶單擊超鏈接時(shí)將下載目標(biāo)。僅當(dāng)設(shè)置了href屬性時(shí),才使用此屬性。該屬性的值將是下載文件的名稱。對允許的值沒有限制,瀏覽器將自動檢測正確的文件擴(kuò)展名并將其添加到文件(.img,.pdf,.txt,.html等)中。如果省略該值,則使用原始文件名。
一個(gè)帶有可點(diǎn)擊下載區(qū)域的圖片:
<!DOCTYPE html> <html> <title>HTML:<area> download 屬性 - 菜鳥教程 (cainiaoplus.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>測試看看 ?/?
IEFirefoxOperaChromeSafari
目前只有Firefox 和 Chrome支持download 屬性。
download屬性指定當(dāng)用戶單擊超鏈接時(shí)將下載目標(biāo)。
僅當(dāng)設(shè)置了href屬性時(shí),才使用此屬性。
該屬性的值將是下載文件的名稱。對允許的值沒有限制,瀏覽器將自動檢測正確的文件擴(kuò)展名并將其添加到文件(.img,.pdf,.txt,.html等)中。
如果省略該值,則使用原始文件名。
download屬性是HTML5中<area>標(biāo)記的新屬性.
<area download="filename">
值 | 描述 |
---|---|
filename | 指定文件名稱。 |