diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/htmlimageelement/decoding | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/htmlimageelement/decoding')
-rw-r--r-- | files/zh-cn/web/api/htmlimageelement/decoding/index.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlimageelement/decoding/index.html b/files/zh-cn/web/api/htmlimageelement/decoding/index.html new file mode 100644 index 0000000000..2bffa6f664 --- /dev/null +++ b/files/zh-cn/web/api/htmlimageelement/decoding/index.html @@ -0,0 +1,63 @@ +--- +title: HTMLImageElement.decoding +slug: Web/API/HTMLImageElement/decoding +translation_of: Web/API/HTMLImageElement/decoding +--- +<div>{{APIRef}}</div> + +<div>{{domxref("HTMLImageElement")}} 接口的 <strong><code>decoding</code></strong> 属性用于告诉浏览器使用何种方式解析图像数据。</div> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox"><var>refStr</var> = <var>imgElem</var>.decoding; +<var>imgElem</var>.decoding = <var>refStr</var>;</pre> + +<h3 id="Values">Values</h3> + +<p>使用 {{domxref("DOMString")}} 表示解码方式. 可使用以下值:</p> + +<dl> + <dd> + <ul> + <li><strong><code>sync</code></strong>: 同步解码图像,保证与其他内容一起显示。</li> + <li><strong><code>async</code></strong>: 异步解码图像,加快显示其他内容。</li> + <li><strong><code>auto</code></strong>: 默认模式,表示不偏好解码模式。由浏览器决定哪种方式更适合用户。</li> + </ul> + </dd> +</dl> + +<h2 id="Usage_notes">Usage notes</h2> + +<p><code>decoding</code> 属性使您可以控制是否允许浏览器尝试异步加载图像。如果这样做会引起问题,您可指定值为 <code>sync</code> 禁止异步加载。异步加载对 {{HTMLElement("img")}} 元素很有用,对屏幕外的图像对象可能会更有用。</p> + +<h2 id="Examples">Examples</h2> + +<pre class="brush: js;highlight:[3]">var img = new Image(); +img.decoding = 'sync'; +img.src = 'img/logo.png'; +</pre> + +<h2 id="Specifications" name="Specifications">Specifications</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', 'embedded-content.html#dom-img-decoding', 'decoding')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.HTMLImageElement.decoding")}}</p> |