The Document.close() method finishes writing to a document, opened with Document.open().
close()
None.
None (undefined).
// Open a document to write to it
document.open();
// Write the content of the document
document.write("<p>The one and only content.</p>");
// Close the document
document.close();
| Specification |
|---|
| HTML> # dom-document-close-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
close |
45 | 12 | 69 | 51 | 11 | 45 | 79 | 47 | 11 | 5.0 | 45 | 11 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/close