此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Document:close() 方法

Deprecated

Avoid using this feature in new projects. The dynamic markup insertion API, which includes document.write(), has "very idiosyncratic behavior" which can be difficult to debug. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: DOM.

Document.close() 方法用于完成对使用 Document.open() 打开的文档的写入。

语法

js
close()

参数

无。

返回值

无(undefined)。

示例

js
// 打开文档并写入
document.open();

// 在文档中编写内容
document.write("<p>独一无二的内容。</p>");

// 关闭文档
document.close();

规范

规范
HTML
# dom-document-close-dev

浏览器兼容性