Open an output stream, add some text, then close the output stream:
Click the button to open an output stream, add some text, and close the output stream.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w w w .jav a 2 s.co m*/ document.open(); document.write("<h1>Hello World</h1>"); document.close(); } </script> </body> </html>
The close()
method closes the output stream opened with the document.open()
method.