aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/htmlanchorelement/download/index.html
blob: fa3f92be86623bc2bde8fb11e3bcc082bca0d0b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: HTMLAnchorElement.download
slug: Web/API/HTMLAnchorElement/download
tags:
  - HTML属性
  - 下载
translation_of: Web/API/HTMLAnchorElement/download
---
<div>{{APIRef("HTML DOM")}}</div>

<p><code><strong>HTMLAnchorElement.download</strong></code>属性是一个{{jsxref("DOMString")}} ,表明链接的资源将被下载,而不是显示在浏览器中。该值表示下载文件的建议名称。如果该名称不是基础操作系统的有效文件名,浏览器将对其进行调整。</p>

<div class="blockIndicator note">
<p><strong>注意</strong>: 该值对于下载行为来说不一定是有用的,同时也不能决定下载行为是否发生。</p>
</div>

<h2 id="语法">语法</h2>

<pre class="syntaxbox notranslate">var <em>dnload</em> = <em>anchorElt</em>.download;
<em>anchorElt</em>.download = <em>dnload</em>;
</pre>

<h2 id="规范Edit">规范<a class="button section-edit only-icon" href="https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLImageElement$edit#规范" rel="nofollow, noindex"><span>Edit</span></a></h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'multipage/text-level-semantics.html#dom-a-download', 'download')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>No change from {{SpecName("DOM2 HTML")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器的兼容性">浏览器的兼容性</h2>

<div>
<p>{{Compat("api.HTMLAnchorElement.download")}}</p>
</div>