HTML DOM Document close()
Example
Open a document, write some text to it, and close it:
document.open();
document.write("<h1>Hello World</h1>");
document.write("<p>Open owerwrites original content.</p>");
document.close();
Try it Yourself »
Open a new window, then open a document, write some text to it, and close it:
const myWindow = window.open();
myWindow.document.open();
myWindow.document.write("<h1>Hello World!</h1>");
myWindow.document.close();
Try it Yourself »
Definition and Usage
The close() method closes a window
previously opened with the open() method.
See Also:
Related:
Warning
The document.open() method clears the document (overwrites all previous content).
Syntax
document.close()
Parameters
| NONE | 
Return Value
| NONE | 
Browser Support
document.close() is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
| Chrome | IE | Edge | Firefox | Safari | Opera | 
| Yes | 9-11 | Yes | Yes | Yes | Yes | 
 
 
