aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/document/exitfullscreen/index.html
blob: c691c88bb561c17fad619fe08daaad33bd2b8d76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
title: Document.exitFullscreen()
slug: Web/API/Document/exitFullscreen
translation_of: Web/API/Document/exitFullscreen
---
<div>{{ApiRef("Fullscreen API")}}</div>

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

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

<h2 id="语法">语法</h2>

<pre class="syntaxbox">document.exitFullscreen();
</pre>

<h2 id="示例">示例</h2>

<pre class="brush: js">// 点击切换全屏模式
document.onclick = function (event) {
  if (document.fullscreenElement) {
    document.exitFullscreen()
  } else {
    document.documentElement.requestFullscreen()
  }
};</pre>

<h2 id="API规格">API规格</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName("Fullscreen", "#dom-document-exitfullscreen", "Document.exitFullscreen()")}}</td>
   <td>{{Spec2("Fullscreen")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

{{Compat("api.Document.exitFullscreen")}}

<h2 id="参阅">参阅</h2>

<ul>
 <li><a href="/en/DOM/Using_full-screen_mode" title="en/DOM/Using full-screen mode">Using full-screen mode</a></li>
 <li>{{ domxref("Element.requestFullscreen()") }}</li>
 <li>{{ domxref("Document.exitFullscreen()") }}</li>
 <li>{{ domxref("Document.fullscreen") }}</li>
 <li>{{ domxref("Document.fullscreenElement") }}</li>
 <li>{{ cssxref(":fullscreen") }}</li>
 <li>{{ HTMLAttrXRef("allowfullscreen", "iframe") }}</li>
</ul>