Document open() Method - Open an output stream with MIME type 'text/html', add some text, then close the output stream: - Javascript DOM

Javascript examples for DOM:Document open

Description

Document open() Method - Open an output stream with MIME type 'text/html', 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() {/*from www .  j a va 2  s. c  om*/
    var w = window.open('text/html');
    w.document.open();
    w.document.write("<h1>Hello World!</h1>");
    w.document.close();
}
</script>

</body>
</html>

Related Tutorials