Document close() Method - Using window.open() with document.open() to open an output stream in a new window, add some text, then close the output stream: - Javascript DOM

Javascript examples for DOM:Document close

Description

Document close() Method - Using window.open() with document.open() to open an output stream in a new window, add some text, then close the output stream:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//  w ww  .  ja  va 2  s .  co  m
    var w = window.open();
    w.document.open();
    w.document.write("<h1>Hello World!</h1>");
    w.document.close();
}
</script>

</body>
</html>

Related Tutorials