From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/document/exitfullscreen/index.html | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 files/zh-cn/web/api/document/exitfullscreen/index.html (limited to 'files/zh-cn/web/api/document/exitfullscreen/index.html') diff --git a/files/zh-cn/web/api/document/exitfullscreen/index.html b/files/zh-cn/web/api/document/exitfullscreen/index.html new file mode 100644 index 0000000000..4cf18e65ff --- /dev/null +++ b/files/zh-cn/web/api/document/exitfullscreen/index.html @@ -0,0 +1,114 @@ +--- +title: Document.exitFullscreen() +slug: Web/API/Document/exitFullscreen +translation_of: Web/API/Document/exitFullscreen +--- +
{{ApiRef("Fullscreen API")}}
+ +

Document.exitFullscreen() 方法用于让当前文档退出全屏模式(原文表述不准确,详见备注)。调用这个方法会让文档回退到上一个调用{{domxref("Element.requestFullscreen()")}}方法进入全屏模式之前的状态。

+ +
备注: 如果一个元素A在请求进去全屏模式之前,已经存在其他元素处于全屏状态,当这个元素A退出全屏模式之后,之前的元素仍然处于全屏状态。浏览器内部维护了一个全屏元素栈用于实现这个目的。
+ +

语法

+ +
document.exitFullscreen();
+
+ +

示例

+ +
// 点击切换全屏模式
+document.onclick = function (event) {
+  if (document.fullscreenElement) {
+    document.exitFullscreen()
+  } else {
+    document.documentElement.requestFullscreen()
+  }
+};
+ +

API规格

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Fullscreen", "#dom-document-exitfullscreen", "Document.exitFullscreen()")}}{{Spec2("Fullscreen")}}Initial definition
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
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}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroid WebkitChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari 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")}}中被实现.

+ +

参阅

+ + -- cgit v1.2.3-54-g00ecf