Node.ownerDocument

这篇翻译不完整。请帮忙从英语翻译这篇文章

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

语法

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

例子

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

备注

The document object returned by this property is the main object with which all the child nodes in the actual HTML document are created.文档节点自身document.ownerDocument返回null.

规范

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

浏览器兼容性

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

文档标签和贡献者

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