Javascript examples for DOM:Document open
The open() method opens an output stream to output from any document.write() or document.writeln() methods.
document.open(MIMEtype, replace);
Parameter | Description |
---|---|
MIMEtype | Optional. The type of document. Default value is "text/html" |
replace | Optional. If to keep history entry |
No return value
The following code shows how to Open an output stream, add some text, then close the output stream:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w w w. j a v a 2 s .c o m document.open(); document.write("<h1>Hello World</h1>"); document.close(); } </script> </body> </html>