From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/htmlimageelement/decoding/index.html | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 files/zh-cn/web/api/htmlimageelement/decoding/index.html (limited to 'files/zh-cn/web/api/htmlimageelement/decoding') 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 +--- +
{{APIRef}}
+ +
{{domxref("HTMLImageElement")}} 接口的 decoding 属性用于告诉浏览器使用何种方式解析图像数据。
+ +

Syntax

+ +
refStr = imgElem.decoding;
+imgElem.decoding = refStr;
+ +

Values

+ +

使用 {{domxref("DOMString")}} 表示解码方式. 可使用以下值:

+ +
+
+
    +
  • sync: 同步解码图像,保证与其他内容一起显示。
  • +
  • async: 异步解码图像,加快显示其他内容。
  • +
  • auto: 默认模式,表示不偏好解码模式。由浏览器决定哪种方式更适合用户。
  • +
+
+
+ +

Usage notes

+ +

decoding 属性使您可以控制是否允许浏览器尝试异步加载图像。如果这样做会引起问题,您可指定值为 sync 禁止异步加载。异步加载对 {{HTMLElement("img")}} 元素很有用,对屏幕外的图像对象可能会更有用。

+ +

Examples

+ +
var img = new Image();
+img.decoding = 'sync';
+img.src = 'img/logo.png';
+
+ +

Specifications

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', 'embedded-content.html#dom-img-decoding', 'decoding')}}{{Spec2('HTML WHATWG')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.HTMLImageElement.decoding")}}

-- cgit v1.2.3-54-g00ecf