HTML DOM adoptNode()Method
Examples
Get the first H1 element in an iframe and insert it into the current 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 is used to get a node from another document.
The node can be any node type.
Note:All child nodes of the node will also be obtained.
Note:The node and its child nodes will be removed from the source document.
Tip:Usedocument.importNode()method to copy the node, but the node in the original document will not be removed.
Tip:Useelement.cloneNode()method to copy a node from the current document, and the node will not be removed.
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. A node from another document. It can be any node type. |
Technical Details
| DOM Version: | Core Level 3 Document Object |
|---|---|
| Return Value: | A Node object, representing the adopted node |
Other Extensions
Document Object