概要
ownerDocument プロパティは、指定ノードを内包するノードツリーのトップレベルのドキュメントオブジェクトを返します。
構文
document = element.ownerDocument
document: 指定要素の祖先であるdocumentオブジェクト
例
var doc = p.ownerDocument; // ノード p のノードツリー上のトップレベル document オブジェクトを取得 var html = doc.documentElement; // owner のドキュメント要素を取得 alert(html); // [object HTMLHtmlElement]
注記
このプロパティによって返される document オブジェクトは、実際の HTML 文書中ですべての子ノードの属するメインオブジェクトです。document ノード自身に対しこのプロパティを用いた場合、戻り値は null となります。
仕様
| Specification | Status | Comment |
|---|---|---|
| DOM4 Node.ownerDocument の定義 |
草案 | |
| Document Object Model (DOM) Level 3 Core Specification Node.ownerDocument の定義 |
勧告 | No change |
| Document Object Model (DOM) Level 2 Core Specification Node.ownerDocument の定義 |
勧告 | Initial definition |
ブラウザ実装状況
| 機能 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| 基本サポート | ? | ? | ? | ? | ? |
| 機能 | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| 基本サポート | ? | ? | ? | ? | ? |
[1] Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6), the ownerDocument of doctype nodes (that is, nodes for which Node.nodeType is Node.DOCUMENT_TYPE_NODE or 10) is no longer null. Instead, the ownerDocument is the document on which document.implementation.createDocumentType() was called.
[2] https://msdn.microsoft.com/en-us/library/ie/ms534315(v=vs.85).aspx