This page is Not Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

adoptNode

Summary

Tries to move a node from one document to the document that the document object displays. It is preferable to use importNode instead.

Method of dom/Documentdom/Document

Syntax

var element = document.adoptNode(/* see parameter list */);

Parameters

element

Data-type
DOM Node

The element to move.

Return Value

Returns an object of type DOM NodeDOM Node

The node that has been moved, or a null value if the node cannot be moved.

Examples

The following code example illustrates the adoptNode method and shows one way to handle cases where the method fails.

var oNode = document.adoptNode( oXHTMLNode );
if ( oNode == null )
   oNode = document.importNode( oXHTMLNode );
parent.appendChild( oNode );

Related specifications

DOM Level 3 Core
Recommendation

Attributions