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() {/* w w w .ja va 2s.co m*/ document.open("text/html", "replace"); document.write("<html><body><p>Hello World!</p></body></html>"); document.close(); } </script> </body> </html>