<html>
<body>
<h1>Document 对象</h1>
<h2>adoptNode() 方法</h2>
<iframe id="myFrame" src="/default.asp" style="height:380px;width:520px;"></iframe>
<p>点击“试一试”可采用 iframe 中的第一个 H1 元素。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
const frame = document.getElementById("myFrame");
const h1 = frame.contentWindow.document.getElementsByTagName("H1")[0];
const node = document.adoptNode(h1);
document.body.appendChild(node);
}
</script>
</body>
</html>