document.adoptNode

  • Revision slug: DOM/document.adoptNode
  • Revision title: document.adoptNode
  • Revision id: 113604
  • Created:
  • Creator: Ptak82
  • Is current revision? No
  • Comment pl

Revision Content

{{template.DomRef()}}

Summary

Adopts a node from an external document. The node and its subtree is removed from the document it's in (if any), and its ownerDocument is changed to the current document. The node can then be inserted into the current document.

Supported since Gecko 1.9 (Firefox 3)

Syntax

var node = document.adoptNode(externalNode);
  • node is the adopted node that can be used in the current document. The new node's parentNode is null, since it has not yet been inserted into the document tree.
  • externalNode is the node from another document to be adopted.

Example

Notes

In general the adoptNode call may fail due to the source node coming from a different implementation, however this should not be a problem with browser implementations.

{{wiki.template(':en/DOM/WRONG_DOCUMENT_ERR_note')}}

Specification

DOM Level 3 Core: Document.adoptNode

{{ wiki.languages( { "pl": "pl/DOM/document.adoptNode" } ) }}

Revision Source

<p>
{{template.DomRef()}}
</p>
<h3 name="Summary"> Summary </h3>
<p>Adopts a node from an external document. The node and its subtree is removed from the document it's in (if any), and its <code><a href="en/DOM/element.ownerDocument">ownerDocument</a></code> is changed to the current document. The node can then be inserted into the current document.
</p><p><b>Supported since Gecko 1.9 (Firefox 3)</b>
</p>
<h3 name="Syntax">Syntax </h3>
<pre class="eval">var <i>node</i> = <i>document</i>.adoptNode(<i>externalNode</i>);
</pre>
<ul><li> <code>node</code> is the adopted node that can be used in the current document. The new node's <code><a href="en/DOM/element.parentNode">parentNode</a></code> is <code>null</code>, since it has not yet been inserted into the document tree.
</li><li> <code>externalNode</code> is the node from another document to be adopted.
</li></ul>
<h3 name="Example"> Example </h3>
<h3 name="Notes"> Notes </h3>
<p>In general the <code>adoptNode</code> call may fail due to the source node coming from a different implementation, however this should not be a problem with browser implementations.
</p><p>{{wiki.template(':en/DOM/WRONG_DOCUMENT_ERR_note')}}
</p>
<h3 name="Specification"> Specification </h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-adoptNode">DOM Level 3 Core: Document.adoptNode</a>
</p>{{ wiki.languages( { "pl": "pl/DOM/document.adoptNode" } ) }}
Revert to this revision