From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/node/ownerdocument/index.html | 115 ++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 files/zh-cn/web/api/node/ownerdocument/index.html (limited to 'files/zh-cn/web/api/node/ownerdocument') diff --git a/files/zh-cn/web/api/node/ownerdocument/index.html b/files/zh-cn/web/api/node/ownerdocument/index.html new file mode 100644 index 0000000000..f1af625761 --- /dev/null +++ b/files/zh-cn/web/api/node/ownerdocument/index.html @@ -0,0 +1,115 @@ +--- +title: Node.ownerDocument +slug: Web/API/Node/ownerDocument +tags: + - API + - DOM + - Gecko + - Property + - 属性 +translation_of: Web/API/Node/ownerDocument +--- +
{{ APIRef("DOM")}}
+ +

Node.ownerDocument 只读属性会返回当前节点的顶层的 document 对象。

+ +

语法

+ +
document = node.ownerDocument
+
+ + + +

例子

+ +
// 得到p元素所在文档的HTML节点
+d = p.ownerDocument;
+html = d.documentElement;
+
+ +

注意

+ +

被此属性返回的 document 对象是在实际的HTML文档中的所有子节点所属的主对象。如果在文档节点自身上使用此属性,则结果是null

+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("DOM4", "#dom-node-ownerdocument", "Node.ownerDocument")}}{{Spec2("DOM4")}} 
{{SpecName("DOM3 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}}{{Spec2("DOM3 Core")}}No change
{{SpecName("DOM2 Core", "core.html#node-ownerDoc", "Node.ownerDocument")}}{{Spec2("DOM2 Core")}}Initial definition
+ +

浏览器兼容性

+ +

{{ CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}[1]6.0[2]{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatUnknown() }}{{ CompatUnknown() }}[1]{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
+
+ +

[1] 从 Gecko 9.0 {{ geckoRelease("9.0") }} 开始, 一个由脚本生成的DocumentType类型的节点(节点类型{{ domxref("Node.nodeType") }}的值为 Node.DOCUMENT_TYPE_NODE 也就是 10)的ownerDocument属性的值不再是null. 而是调用document.implementation.createDocumentType() 方法创建该节点的文档节点.

+ +

[2] http://msdn.microsoft.com/en-us/library/ie/ms534315(v=vs.85).aspx

-- cgit v1.2.3-54-g00ecf