Latest web development tutorials

HTML DOM importNode () method

Document Object Reference Document Object

Examples

Back in the first H1 iframe element:

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

importNode () method to copy a node from another document to this document to apply.

imported node can try any node type.

If the second value is set to true, then also copy all descendants of this node.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support importNode () method

NOTE: Internet explorer 8 and earlier versions of IE does not support this method.


grammar

document.importNode( node , deep )

parameter

参数 类型 描述
deep Boolean 必须。如果为 true,还要递归复制 importedNode 节点的所有子孙节点。

return value

类型 描述
Node object The imported node

technical details

DOM version Core Level 2 Document Object


Document Object Reference Document Object