Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM importNode() method

HTML DOM importNode() method

Document Object Reference Document Object

Example

Return the first H1 element in the iframe:

var frame=document.getElementsByTagName("iframe")[0]

var h=frame.contentWindow.document.getElementsByTagName("h1")[0];

var x=document.importNode(h,true);

Try it »


Definition and Usage

The importNode() method copies a node from another document into this document for use.

The imported node can be of any node type.

If the second value is set to true, then all descendant nodes of that node will also be copied.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the importNode() method

Note: Internet Explorer 8 and earlier IE versions do not support this method.


Syntax

document.importNode(

node

,

deep

)

Parameters

Parameters Type Description
deep Boolean Required. If true, all descendant nodes of the importedNode will also be copied recursively.

Return Value

Type Description
Node object The imported node

Technical Details

DOM version Core Level 2 Document Object

Document Object Reference Document Object