Visit Mozilla.org

DOM:document.adoptNode

z Mozilla Developer Center, polskiego centrum programistów Mozilli.

« Dokumentacja Gecko DOM

UWAGA: Tłumaczenie tej strony nie zostało zakończone.
Może być ona niekompletna lub wymagać korekty.
Chcesz pomóc? | Dokończ tłumaczenie | Sprawdź ortografię | Więcej takich stron...

Spis treści

[edytuj] Podsumowanie

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)

[edytuj] Składnia

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.

[edytuj] Przykład

[edytuj] Uwagi

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.

Przed włączeniem węzłów pochodzących z zewnętrznych dokumentów do bieżącego dokumentu konieczne jest ich sklonowanie za pomocą metody importNode (lub zaadaptowanie przy użyciu metody adoptNode). Więcej informacji na temat własności ownerDocument znajduje się na liście najczęściej zadawanych pytań na temat DOM w witrynie W3C.

W silniku Gecko w wersjach starszych niż 1.9 używanie metody importNode oraz adoptNode nie jest wymuszane. Od wersji 1.9 brak adaptacji lub importu węzła przed jego użyciem w innym dokumencie spowoduje wystąpienie błędu WRONG_DOCUMENT_ERR (NS_ERROR_DOM_WRONG_DOCUMENT_ERR).




[edytuj] Specyfikacja

DOM Level 3 Core: Document.adoptNode