--- title: Node.ownerDocument slug: Web/API/Node/ownerDocument translation_of: Web/API/Node/ownerDocument ---
{{APIRef("DOM")}}

Node.ownerDocument 唯讀屬性會回傳一個此節點所屬的的頂層 document 物件。

語法

document = element.ownerDocument

範例

// given a node "p", get the top-level HTML child
// of the document object

var d = p.ownerDocument;
var 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. If this property is used on a node that is itself a document, the result is null.

規範

Specification Status Comment
{{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

瀏覽器相容性

{{Compat("api.Node.ownerDocument")}}