From d4b97cd8ba7c9b71d5e3ccb119103047da3b44a8 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Mon, 2 Aug 2021 10:31:29 -0400 Subject: remove link 'title' attributes that's just the 'href' (zh-cn, part 6) --- files/zh-cn/web/api/element/getattribute/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'files/zh-cn/web/api/element/getattribute') diff --git a/files/zh-cn/web/api/element/getattribute/index.html b/files/zh-cn/web/api/element/getattribute/index.html index 2310d18095..ed9673bde5 100644 --- a/files/zh-cn/web/api/element/getattribute/index.html +++ b/files/zh-cn/web/api/element/getattribute/index.html @@ -35,7 +35,7 @@ alert(align);

当在被标记为 HTML 文档中的一个 HTML 元素上调用此方法时,getAttribute() 会先将其参数转换为小写形式。

-

当指定的属性不存在于元素上时,所有浏览器(Firefox、Internet Explorer、Opera 最新版本、Safari、Konqueror 以及 iCab 等等)都返回 null,这也是当前 DOM 规范草案规定的。然而,旧的DOM 3 Core specification 认为此时正确的返回值应该是一个空字符串,一些 DOM 实现环境实现了该行为(behavior)。在 XUL (Gecko) 中,getAttribute 的实现遵从 DOM 3 Core specification,返回一个空字符串。因此,如果一个属性可能不存在于指定的元素上,在调用 getAttribute() 之前,你应该使用 {{domxref("element.hasAttribute()")}} 来检测该属性是否存在。

+

当指定的属性不存在于元素上时,所有浏览器(Firefox、Internet Explorer、Opera 最新版本、Safari、Konqueror 以及 iCab 等等)都返回 null,这也是当前 DOM 规范草案规定的。然而,旧的DOM 3 Core specification 认为此时正确的返回值应该是一个空字符串,一些 DOM 实现环境实现了该行为(behavior)。在 XUL (Gecko) 中,getAttribute 的实现遵从 DOM 3 Core specification,返回一个空字符串。因此,如果一个属性可能不存在于指定的元素上,在调用 getAttribute() 之前,你应该使用 {{domxref("element.hasAttribute()")}} 来检测该属性是否存在。

浏览器兼容性

-- cgit v1.2.3-54-g00ecf