Document.close() 用于结束由 对文档的 Document.write() 写入操作,这种写入操作一般由 Document.open() 打开。

语法

document.close();

例子

// 打开一个文档,以便写入数据
document.open();

// 写入文档内容
document.write("<p>文档内容~</p>");

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

规范

规范 状态 备注
HTML Living Standard
document.close()
Living Standard
Document Object Model (DOM) Level 2 HTML Specification
document.close()
Obsolete

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
closeChrome Full support 45
Notes
Full support 45
Notes
Notes Before Chrome 64, this method was accessed through the HTMLDocument alias.
Edge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support 45
Notes
Full support 45
Notes
Notes Before Chrome 64, this method was accessed through the HTMLDocument alias.
Chrome Android Full support 45
Notes
Full support 45
Notes
Notes Before Chrome 64, this method was accessed through the HTMLDocument alias.
Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

文档标签和贡献者

标签: 
此页面的贡献者: RainSlide, mdnwebdocs-bot, teoli, jsx, ziyunfei
最后编辑者: RainSlide,