We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

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

语法

document = node.ownerDocument
  • document 是当前元素的 document 对象,其是当前元素的祖先。

例子

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

注意

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

规范

Specification Status Comment
DOM4
Node.ownerDocument
Obsolete  
Document Object Model (DOM) Level 3 Core Specification
Node.ownerDocument
Obsolete No change
Document Object Model (DOM) Level 2 Core Specification
Node.ownerDocument
Obsolete Initial definition

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes)[1] 6.0[2] (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ?[1] ? ? ?

[1] 从 Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6) 开始, 一个由脚本生成的DocumentType类型的节点(节点类型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

文档标签和贡献者

标签: 
此页面的贡献者: kameii, Ende93, teoli, AshfaqHossain, ziyunfei
最后编辑者: kameii,