ownerDocument
Summary
Retrieves the document object associated with the node.
Syntax
Note: This property is read-only.
var doc = element.ownerDocument;
Return Value
Returns an object of type DOM NodeDOM Node
The document Node of the web page or iframe or frame.
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.
Examples
// given a node "p", get the top-level HTML child
// of the document object
var doc = p.ownerDocument;
alert(doc.outerHTML);
var html = doc.documentElement;
alert(html.outerHTML);
Usage
Used to build the DOM tree of documents that contain <iframe>, <frame> and <frameset> elements.
Notes
Remarks
The ownerDocument is the Document object that is used to create new nodes. This property returns null when the node is a Document. ownerDocument was introduced in Microsoft Internet Explorer 6.
Syntax
var doc=element.ownerDocument;
Related specifications
- DOM Level 2 Core
- Recommendation
Attributions
Mozilla Developer Network : [Node.ownerDocument Article]
Microsoft Developer Network: [ownerDocument Property Article]