如何在 HTML 中指定用户点击超链接时下载目标?

htmlweb developmentfront end technology更新于 2025/8/14 21:00:17

使用 download 属性设置点击超链接时下载的文件。将该属性的值设置为下载文件的名称,例如"image"。

示例

<!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://www.cainiaomax.com/java/images/if_statement.jpg" download>
         <img border = "0" src = "https://www.cainiaomax.com/java/images/if_statement.jpg" alt="Java" width="400" height="450">
      </a>
   </body>
</html>

相关文章


有用资源