HTML DOM Document adoptNode()
Example
Adopt the first <h1> element that appears in an iframe (another document):
const frame = document.getElementById("myFrame");
const h1 = frame.contentWindow.document.getElementsByTagName("H1")[0];
const node = document.adoptNode(h1);
Try it Yourself »
Definition and Usage
The adoptNode()
method adopts a node from another document.
Note
The adopted node can be of all types.
Any child nodes (descendants) of the adopted node, are also adopted.
The original node (with child nodes) is removed from the other document.
See Also:
Syntax
document.adoptNode(node)
Parameters
Parameter | Description |
node | Required. A node from another document. Can be of any node type. |
Return Value
Type | Description |
Node | The adopted node. |
Browser Support
document.adoptNode
is a DOM Level 3 (2004) feature.
It is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 9-11 | Yes | Yes | Yes | Yes |