--- 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 |
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}}{{property_prefix("-webkit")}} {{CompatChrome(45)}} (unprefixed) |
{{CompatGeckoDesktop("9.0")}} as mozCancelFullScreen [1]{{CompatGeckoDesktop("47.0")}}[1] (behind full-screen-api.unprefix.enabled |
{{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android Webkit | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}}{{property_prefix("-webkit")}} {{CompatChrome(45)}} (unprefixed) |
{{CompatVersionUnknown}}{{property_prefix("-webkit")}} {{CompatChrome(45)}} (unprefixed) |
{{CompatGeckoMobile("9.0")}} as mozCancelFullScreen [1]{{CompatGeckoMobile("47.0")}}[1] (behind full-screen-api.unprefix.enabled |
{{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] 可通过Document.exitFullscreen()
方法让全屏元素栈的栈顶元素退出全屏状态,并让新的栈顶的元素进入全屏状态。此特征在Gecko 11.0 {{geckoRelease("11.0")}}中被实现.