Nossos voluntários ainda não traduziram este artigo para o Português (do Brasil). Junte-se a nós e ajude-nos a fazer o trabalho!
Você também pode ler o artigo em English (US).


Adopts a node. 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)


node = document.adoptNode(externalNode);
is the adopted node that now has this document as its ownerDocument. The node's parentNode is null, since it has not yet been inserted into the document tree.  Note that node and externalNode are the same object after this call.  
is the node from another document to be adopted.


var iframe = document.getElementById('my-iframe');
var iframeImages = iframe.contentDocument.getElementsByTagName('img');

var newParent = document.getElementByTagName('images');

for (var i = 0; i < iframeImages.length; i++) {


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.

Nodes from external documents should be cloned using document.importNode() (or adopted using document.adoptNode()) before they can be inserted into the current document. For more on the Node.ownerDocument issues, see the W3C DOM FAQ.

Firefox doesn't currently enforce this rule (it did for a while during the development of Firefox 3, but too many sites break when this rule is enforced). We encourage Web developers to fix their code to follow this rule for improved future compatibility.


Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes ? Yes ? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes ? Yes ? ? ?

See also

Etiquetas do documento e colaboradores

Última atualização por: fscholz,