Document close() Method - Javascript DOM

Javascript examples for DOM:Document close

Description

The close() method closes the output stream opened with the document.open() method, and displays the data.

Return Value:

No return value

The following code shows how to Open an output stream, 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 w  ww.  j  a  v a 2s .c o  m
    document.open();
    document.write("<h1>Hello World</h1>");
    document.close();
}
</script>

</body>
</html>

Related Tutorials