JavaScript document.adoptNode() Method

You are Here:

JavaScript document.adoptNode() Method

The document.adoptNode() method transfers a node from another document into the method's document.

Note: The adopted node and its subtree is removed from its original document (if any), and its ownerDocument is changed to the current document.


HTML Online Editor
<!DOCTYPE html> <html> <body> <iframe src="/js/document-adoptnode/iframe"></iframe> <button onclick="myFunction()">Click me</button> <script> var frame = document.getElementsByTagName("iframe")[0]; function myFunction(){ //Try to change "h1" to "p" var get = frame.contentWindow.document.getElementsByTagName("h1")[0]; var x = document.adoptNode(get); document.body.appendChild(x); } </script> </body> </html>



Parameter Values

externalNodeRequiredThe node from another document to be adopted.


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author