<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
iframe{
height:280px;
width:320px;
display:block;
margin-bottom:10px;
}
</style>
</head>
<body>
<iframe src="/js/document-adoptnode/iframe"></iframe>
<p><strong>Note:</strong> Click on the button to import h1 node from iframe.</p>
<button onclick="myFunction()">Click Me</button>
<script>
var frame = document.getElementsByTagName("IFRAME")[0]
function myFunction() {
var h = frame.contentWindow.document.getElementsByTagName("h1")[0];
var x = document.importNode(h, true);
document.body.appendChild(x);
}
</script> </body>
</html>