如何在 HTML 中指定當使用者點選超連結時下載目標檔案?


使用 download 屬性將檔案設定為在點選超連結時下載。將該屬性的值設定為下載檔案的名稱,例如影像。

示例

<!DOCTYPE html>
<html>
   <body>
      <h3>if statement in Java</h3>
      <p>The following is an image explaining the concept if <b>if-statmement in Java</b> (Click to download):<p>
     
      <a href = "https://tutorialspoint.tw/java/images/if_statement.jpg" download>
         <img border = "0" src = "https://tutorialspoint.tw/java/images/if_statement.jpg" alt="Java" width="400" height="450">
      </a>
   </body>
</html>

更新於: 03 年 3 月 2020 日

121 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

開始吧
檢視廣告