Search w3schools.com:

SHARE THIS PAGE

DOM Document importNode() Method

Document Object Reference Document Object

Example

Return the first H1 element that appears in an iframe:

var frame=document.getElementsByTagName("iframe")[0]
var h=frame.contentWindow.document.getElementsByTagName("h1")[0];
var x=document.importNode(h,true);

Try it yourself »

Definition and Usage

The importNode() method imports a node from another document.

The imported node can be of all node types.

Read more about node types in our NodeType object reference.

If the second parameter is set to true, the nodes's child nodes will also be imported.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The importNode() method is supported in all major browsers.

Note: Internet explorer 8 and earlier does not support this method.


Syntax

document.importNode(node,deep)

Parameters

Parameter Type Description
deep Boolean Required. If set to false, only the node itself is imported, if set to true, all child nodes (descendants) are also imported

Return Value

Type Description
Node object The imported node

Technical Details

DOM Version Core Level 2


Document Object Reference Document Object



W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The HTML5 Certificate documents your knowledge of advanced HTML5.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]