JavaScript » Document » close

Syntax:
document.close( )

This method closes an output stream previously opened with the document.open method and forces data collected from any instances of the document.write or document.writeln methods to be displayed.

This method closes an output stream previously opened with the document.open method and forces data collected from any instances of the document.write or document.writeln methods to be displayed.

Examples

Code:
function newWindowTest() {
  var message1 = "Hello, world!"
  var message2 = "This is a test."
  newWindow.document.open("text/html", "replace")
  newWindow.document.writeln("message1)
  newWindow.document.write("message2)
  newWindow.document.close()
}

newWindow=window.open('','','toolbar=no,scrollbars=no,width=200,height=150')
newWindowTest()
Output:
"Hello, world! This is a test."
Explanation:

This example demonstrates this and displays the output stream in a new window.