HTML DOM adoptNode() Method
Example
Adopt the first <h1> element that appears in an iframe (another document):
var frame = document.getElementsByTagName("IFRAME")[0]
var h = frame.contentWindow.document.getElementsByTagName("H1")[0];
var x = document.adoptNode(h);
Try it Yourself »
Definition and Usage
The adoptNode() method adopts a node from another document.
The adopted node can be of all node types.
Note: All child nodes (descendants), if any, of the adopted node, are also adopted.
Note: The original node (and its child nodes, if any) is removed from the other document.
Tip: Use the document.importNode() method to copy a node, without removing it, from another document.
Tip: Use the element.cloneNode() method to copy a node, without removing it, from the current document.
Browser Support
The numbers in the table specify the first browser version that fully supports the method.
Method | |||||
---|---|---|---|---|---|
adoptNode() | Yes | 9.0 | 3.0 | Yes | 9.0 |
Syntax
document.adoptNode(node)
Parameter Values
Parameter | Type | Description |
---|---|---|
node | Node object | Required. The node from another document. Can be of any node type |
Technical Details
Return Value: | A Node object, representing the adopted node |
---|---|
DOM Version | Core Level 3 Document Object |