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 »
The close()
method closes a window previously opened with the open()
method.
The document.open() method clears the document (overwrites all previous content).
document.close()
NONE |
NONE |
document.close()
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!