/

HTML / CSS / JavaScript Tutorial

JavaScript Document method: importNode()

[this page | pdf | back links]

The importNode() method (when applied to the document object of the JavaScript DOM) imports node from another document (i.e. creates a copy of and inserts the copy into the current document).

 

It has the following syntax with the following parameters. It returns a Node object representing the imported node.

 

document.importNode(node, deepness)

 

Parameter

Required / Optional

Description

node

Required

Node object from other document (any node type is permitted)

deepness

Required

Boolean value, which if false means only import the node itself, but if true then also import all child nodes, i.e. descendents, of the node

 

Note: if you want to copy a node from the current document then use element.cloneNode() and if you want to remove a node from one document an import it into another than use document.adoptNode().

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile