Easy Tutorial
❮ Prop Week Type Jsref Length Array ❯

HTML DOM adoptNode() Method

Document Object

Example

Retrieve the first H1 element from 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);

Definition and Usage

The adoptNode() method is used to retrieve a node from another document.

The node can be of any node type.

Note: All child nodes under the node will be retrieved as well.

Note: The node and its child nodes will be removed from the source document.

Tip: Use the document.importNode() method to copy a node, but the node in the original document will not be removed.

Tip: Use the element.cloneNode() method to copy a node within 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 Chrome IE Firefox Safari Opera
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, which can be of any node type.

Technical Details

DOM Version: Core Level 3 Document Object
Return Value: Node object, representing the retrieved node
--- ---

Document Object

❮ Prop Week Type Jsref Length Array ❯