--- title: Document.exitFullscreen() slug: Web/API/Document/exitFullscreen translation_of: Web/API/Document/exitFullscreen ---
Document.exitFullscreen()
方法用于让当前文档退出全屏模式(原文表述不准确,详见备注)。调用这个方法会让文档回退到上一个调用{{domxref("Element.requestFullscreen()")}}方法进入全屏模式之前的状态。
document.exitFullscreen();
// 点击切换全屏模式 document.onclick = function (event) { if (document.fullscreenElement) { document.exitFullscreen() } else { document.documentElement.requestFullscreen() } };
Specification | Status | Comment |
---|---|---|
{{SpecName("Fullscreen", "#dom-document-exitfullscreen", "Document.exitFullscreen()")}} | {{Spec2("Fullscreen")}} | Initial definition |