aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/element/onfullscreenerror/index.html
blob: de9e5353c442a9056a67b4434e9c7307379b21f6 (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
60
61
62
63
64
---
title: Element.onfullscreenerror
slug: Web/API/Element/onfullscreenerror
translation_of: Web/API/Element/onfullscreenerror
---
<div>{{ApiRef("Fullscreen API")}}</div>

<p><span class="seoSummary">{{domxref("Element")}} 接口的 <code><strong>onfullscreenerror</strong></code> 属性是在{{domxref("Element")}} 过渡到或退出全屏模式发生错误后处理事件{{event("fullscreenerror")}}的事件处理程序。</span></p>

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

<pre class="syntaxbox"><var>targetElement</var>.onfullscreenerror = <var>fullscreenErrorHandler</var>;
</pre>

<h3 id="值"></h3>

<p>一个处理事件{{event("fullscreenerror")}}的事件处理程序.</p>

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

<p>本示例尝试不从用户发起的事件(如点击事件{{event("click")}}或键盘事件{{event("keypress")}})处理程序来触发全屏,由于全屏模式只允许由用户主动输入触发,因此该操作会发生错误,从而导致<span class="seoSummary">{{domxref("Element")}}</span>触发{{event("fullscreenerror")}}事件传递给错误处理程序</p>

<pre class="brush: js">let elem = document.querySelector("video")}}

elem.onfullscreenerror = function ( event ) {
  displayWarning("Unable to switch into full-screen mode.");
};

//....

elem.requestFullscreen();</pre>

<h2 id="规范">规范</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-element-onfullscreenerror", "onfullscreenerror")}}</td>
   <td>{{Spec2("HTML WHATWG")}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

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



<p>{{Compat("api.Element.onfullscreenerror")}}</p>

<h2 id="其他">其他</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/Fullscreen_API">Fullscreen API </a></li>
 <li><a href="/en-US/docs/Web/API/Fullscreen_API/Guide">Guide to the Fullscreen API</a></li>
 <li>{{event("fullscreenerror")}}</li>
 <li>{{domxref("Element.onfullscreenchange")}}</li>
 <li>{{domxref("Document.onfullscreenerror")}}</li>
</ul>