<html>
<body>
<h1>The Document Object</h1>
<h2>The open() and close() Methods</h2>
<p>Click "Open" to open a document in a new window, write some text to it and close it:</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
const myWindow = window.open();
myWindow.document.open();
myWindow.document.write("<h1>Hello World!</h1>");
myWindow.document.close();
}
</script>
</body>
</html>