A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/Document/importNode below:

Document: importNode() method - Web APIs

Document: importNode() method

Baseline Widely available

The Document object's importNode() method creates a copy of a Node or DocumentFragment from another document, to be inserted into the current document later.

The imported node is not yet included in the document tree. To include it, you need to call an insertion method such as appendChild() or insertBefore() with a node that is currently in the document tree.

Unlike document.adoptNode(), the original node is not removed from its original document. The imported node is a clone of the original.

Syntax
importNode(externalNode)
importNode(externalNode, deep)
Parameters
externalNode

The external Node or DocumentFragment to import into the current document.

deep Optional

A boolean flag, whose default value is false, which controls whether to include the entire DOM subtree of the externalNode in the import.

Return value

The copied importedNode in the scope of the importing document.

Note: importedNode's Node.parentNode is null, since it has not yet been inserted into the document tree!

Examples
const iframe = document.querySelector("iframe");
const oldNode = iframe.contentWindow.document.getElementById("myNode");
const newNode = document.importNode(oldNode, true);
document.getElementById("container").appendChild(newNode);
Notes

Before they can be inserted into the current document, nodes from external documents should either be:

Note: Although Firefox doesn't currently enforce this rule, we encourage you to follow this rule for improved future compatibility.

For more on the Node.ownerDocument issues, see the W3C DOM FAQ.

Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3