Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt Document fullscreen events to new structure #12926

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7617,6 +7617,8 @@
/en-US/docs/Web/API/Document/oncontextmenu /en-US/docs/Web/API/GlobalEventHandlers/oncontextmenu
/en-US/docs/Web/API/Document/ondblclick /en-US/docs/Web/API/GlobalEventHandlers/ondblclick
/en-US/docs/Web/API/Document/onfocus /en-US/docs/Web/API/GlobalEventHandlers/onfocus
/en-US/docs/Web/API/Document/onfullscreenchange /en-US/docs/Web/API/Document/fullscreenchange_event
/en-US/docs/Web/API/Document/onfullscreenerror /en-US/docs/Web/API/Document/fullscreenerror_event
/en-US/docs/Web/API/Document/oninput /en-US/docs/Web/API/GlobalEventHandlers/oninput
/en-US/docs/Web/API/Document/onkeydown /en-US/docs/Web/API/GlobalEventHandlers/onkeydown
/en-US/docs/Web/API/Document/onkeypress /en-US/docs/Web/API/GlobalEventHandlers/onkeypress
Expand Down Expand Up @@ -7903,8 +7905,8 @@
/en-US/docs/Web/API/GlobalEventHandlers/dragexit_event /en-US/docs/Web/API/Document/dragleave_event
/en-US/docs/Web/API/GlobalEventHandlers/oncuechange /en-US/docs/Web/API/TextTrack/cuechange_event
/en-US/docs/Web/API/GlobalEventHandlers/ondragexit /en-US/docs/Web/API/GlobalEventHandlers/ondragleave
/en-US/docs/Web/API/GlobalEventHandlers/onmozfullscreenchange /en-US/docs/Web/API/Document/onfullscreenchange
/en-US/docs/Web/API/GlobalEventHandlers/onmozfullscreenerror /en-US/docs/Web/API/Document/onfullscreenerror
/en-US/docs/Web/API/GlobalEventHandlers/onmozfullscreenchange /en-US/docs/Web/API/Document/fullscreenchange_event
/en-US/docs/Web/API/GlobalEventHandlers/onmozfullscreenerror /en-US/docs/Web/API/Document/fullscreenerror_event
/en-US/docs/Web/API/GlobalEventHandlers/onpointerdown/drag /en-US/docs/Web/API/GlobalEventHandlers/ondrag
/en-US/docs/Web/API/GlobalFetch/GlobalFetch.fetch() /en-US/docs/Web/API/fetch
/en-US/docs/Web/API/GlobalFetch/fetch /en-US/docs/Web/API/fetch
Expand Down
24 changes: 0 additions & 24 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -38175,30 +38175,6 @@
"Johnjbarton"
]
},
"Web/API/Document/onfullscreenchange": {
"modified": "2020-10-15T21:46:43.611Z",
"contributors": [
"mfuji09",
"vasklund",
"Sheppy",
"fscholz",
"adyouri",
"jpmedley",
"SphinxKnight",
"sebastianross",
"teoli"
]
},
"Web/API/Document/onfullscreenerror": {
"modified": "2020-10-15T21:46:44.196Z",
"contributors": [
"mfuji09",
"Sheppy",
"fscholz",
"jpmedley",
"teoli"
]
},
"Web/API/Document/onoffline": {
"modified": "2019-03-23T23:14:56.082Z",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/49/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ tags:

- {{domxref("XMLHttpRequest.getResponseHeader()")}} and {{domxref("XMLHttpRequest.getAllResponseHeaders()")}} return empty headers in case the preference `network.http.keep_empty_response_headers_as_empty_string` is set to `true` ({{bug(669259)}}).
- The Firefox OS-only [Data Store API](/en-US/docs/Archive/Firefox_OS/API/Data_Store_API) has been removed ({{bug(1261009)}}).
- The [Fullscreen API](/en-US/docs/Web/API/Fullscreen_API) event handlers {{domxref("Document.onfullscreenchange")}} and {{domxref("Document.onfullscreenerror")}} have been removed from {{domxref("Element")}} as they were never fired there; the prefixed versions of these event handlers have been kept there for compatibility purposes, however ({{bug(1270386)}}). Note that this is not yet activated by default, but is behind the `full-screen-api.unprefix.enabled` preference ({{bug(1268749)}}).
- The [Fullscreen API](/en-US/docs/Web/API/Fullscreen_API) event handlers `Document.onfullscreenchange` and `Document.onfullscreenerror` have been removed from {{domxref("Element")}} as they were never fired there; the prefixed versions of these event handlers have been kept there for compatibility purposes, however ({{bug(1270386)}}). Note that this is not yet activated by default, but is behind the `full-screen-api.unprefix.enabled` preference ({{bug(1268749)}}).
- The obsolete `Document.mozFullScreen` property has been unprefixed to {{domxref("Document.fullscreen")}} {{bug(1269157)}}. Note that this is not yet activated by default by behind the `full-screen-api.unprefix.enabled` preference ({{bug(1268749)}}).
- The read-only properties {{domxref("Document/fullscreenElement", "Document.fullscreenElement")}} and {{domxref("Document.fullscreenEnabled")}} no longer throw an exception if an attempt is made to change their values; instead, the new value is silently ignored and the setter function is a no-op ({{bug(1269798)}}).
- Any kind of data can now be retrieved from the clipboard using {{domxref("DataTransfer.getData()")}}: previously, only data of certain MIME types were supported {{bug(860857)}}.
Expand Down
53 changes: 21 additions & 32 deletions files/en-us/web/api/document/fullscreenchange_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,39 @@ browser-compat: api.Document.fullscreenchange_event
---
{{APIRef}}

The `fullscreenchange` event is fired immediately after the browser switches into or out of full-screen mode.

<table class="properties">
<tbody>
<tr>
<th scope="row">Bubbles</th>
<td>Yes</td>
</tr>
<tr>
<th scope="row">Cancelable</th>
<td>No</td>
</tr>
<tr>
<th scope="row">Interface</th>
<td>{{domxref("Event")}}</td>
</tr>
<tr>
<th scope="row">Event handler property</th>
<td>
{{domxref("Document.onfullscreenchange", "onfullscreenchange")}}
</td>
</tr>
</tbody>
</table>

The event is sent to the `Element` that is transitioning into or out of full-screen mode, and this event then bubbles up to the `Document`.

To find out whether the `Element` is entering or exiting full-screen mode, check the value of {{domxref("Document.fullscreenElement")}}: if this value is `null` then the element is exiting full-screen mode, otherwise it is entering full-screen mode.
The `fullscreenchange` event is fired immediately after the browser switches into or out of fullscreen mode.

The event is sent to the `Element` that is transitioning into or out of fullscreen mode, and this event then bubbles up to the `Document`.

To find out whether the `Element` is entering or exiting fullscreen mode, check the value of {{domxref("Document.fullscreenElement")}}: if this value is `null` then the element is exiting fullscreen mode, otherwise it is entering fullscreen mode.

This event is not cancelable.

## Examples

In this example, a handler for the `fullscreenchange` event is added to the {{domxref("Document")}}.

```js
document.addEventListener('fullscreenchange', (event) => {
function fullscreenchanged = (event) => {
// document.fullscreenElement will point to the element that
// is in fullscreen mode if there is one. If there isn't one,
// the value of the property is null.
if (document.fullscreenElement) {
console.log(`Element: ${document.fullscreenElement.id} entered full-screen mode.`);
console.log(`Element: ${document.fullscreenElement.id} entered fullscreen mode.`);
} else {
console.log('Leaving full-screen mode.');
console.log('Leaving fullscreen mode.');
}
});
}

document.addEventListener('fullscreenchange', fullscreenchanged);
// or
document.onfullscreenchange = fullscreenchanged;

// When the element is clicked, enter fullscreen
myFullscreenElement.onclick = function () {
// requestFullscreen() must be in an event handler or it will fail
myFullscreenElement.requestFullscreen();
}
```

See [Element: fullscreenchange event](/en-US/docs/Web/API/Element/fullscreenchange_event) for another example.
Expand Down
38 changes: 11 additions & 27 deletions files/en-us/web/api/document/fullscreenerror_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: 'Document: fullscreenerror event'
slug: Web/API/Document/fullscreenerror_event
tags:
- API
- Error
- Event
- Fullscreen API
- Reference
Expand All @@ -13,34 +12,13 @@ browser-compat: api.Document.fullscreenerror_event
---
{{APIRef}}

The `fullscreenerror` event is fired when the browser cannot switch to full-screen mode.

<table class="properties">
<tbody>
<tr>
<th scope="row">Bubbles</th>
<td>Yes</td>
</tr>
<tr>
<th scope="row">Cancelable</th>
<td>No</td>
</tr>
<tr>
<th scope="row">Interface</th>
<td>{{domxref("Event")}}</td>
</tr>
<tr>
<th scope="row">Event handler property</th>
<td>
{{domxref("Document.onfullscreenerror", "onfullscreenerror")}}
</td>
</tr>
</tbody>
</table>
The `fullscreenerror` event is fired when the browser cannot switch to fullscreen mode.

As with the [`fullscreenchange` event](/en-US/docs/Web/API/Document/fullscreenchange_event), two `fullscreenerror` events are fired; the first is sent to the {{domxref("Element")}} which failed to change modes, and the second is sent to the {{domxref("Document")}} which owns that element.

For some reasons that switching into full-screen mode might fail, see [the guide to the Fullscreen API](/en-US/docs/Web/API/Fullscreen_API/Guide).
For some reasons that switching into fullscreen mode might fail, see [the guide to the Fullscreen API](/en-US/docs/Web/API/Fullscreen_API/Guide).

This event is not cancelable.

## Examples

Expand All @@ -51,6 +29,11 @@ document.addEventListener('fullscreenerror', (event) => {
console.error('an error occurred changing into fullscreen');
console.log(event);
});
// or
document.onfullscreenerror = (event) => {
console.error('an error occurred changing into fullscreen');
console.log(event);
});

requestor.requestFullscreen();
```
Expand All @@ -65,6 +48,7 @@ requestor.requestFullscreen();

## See also

- [`fullscreenchange`](/en-US/docs/Web/API/Document/fullscreenchange_event)
- {{domxref("Document/fullscreenchange_event", "fullscreenchange")}}
- {{domxref("Element")}}: {{domxref("Element/fullscreenerror_event", "fullscreenerror")}} event
- [Fullscreen API](/en-US/docs/Web/API/Fullscreen_API)
- [Guide to the Fullscreen API](/en-US/docs/Web/API/Fullscreen_API/Guide)
5 changes: 0 additions & 5 deletions files/en-us/web/api/document/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ _The `Document` interface is extended with additional event handlers defined in
- : Represents the event handling code for the {{domxref("Document/copy_event", "copy")}} event.
- {{DOMxRef("Document.oncut")}} {{Non-standard_Inline}}
- : Represents the event handling code for the {{domxref("Document/cut_event", "cut")}} event.
- {{DOMxRef("Document.onfullscreenchange")}}
- : Is an [event handler](/en-US/docs/Web/Events/Event_handlers) representing the code to be called when the {{domxref("Document/fullscreenchange_event", "fullscreenchange")}} event is raised.
- {{DOMxRef("Document.onfullscreenerror")}}
- : Is an [event handler](/en-US/docs/Web/Events/Event_handlers) representing the code to be called when the {{domxref("Document/fullscreenerror_event", "fullscreenerror")}} event is raised.
- {{DOMxRef("Document.onpaste")}} {{Non-standard_Inline}}
- : Represents the event handling code for the {{domxref("Document/paste_event", "paste")}} event.
- {{DOMxRef("Document.onreadystatechange")}}
Expand Down Expand Up @@ -394,7 +390,6 @@ Listen to these events using `addEventListener()` or by assigning an event liste

- {{DOMxRef("Document/fullscreenchange_event", "fullscreenchange")}}
- : Fired when the `Document` transitions into or out of [full-screen](/en-US/docs/Web/API/Fullscreen_API/Guide) mode.
Also available via the {{DOMxRef("Document.onfullscreenchange", "onfullscreenchange")}} property.
- [`fullscreenerror`](/en-US/docs/Web/API/Document/fullscreenerror_event)
- : Fired if an error occurs while attempting to switch into or out of [full-screen](/en-US/docs/Web/API/Fullscreen_API/Guide) mode.
Also available via the {{DOMxRef("Document.onfullscreenerror", "onfullscreenerror")}} property.
Expand Down
67 changes: 0 additions & 67 deletions files/en-us/web/api/document/onfullscreenchange/index.md

This file was deleted.

66 changes: 0 additions & 66 deletions files/en-us/web/api/document/onfullscreenerror/index.md

This file was deleted.

16 changes: 0 additions & 16 deletions files/en-us/web/api/fullscreen_api/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,6 @@ For the moment not all browsers are implementing the unprefixed version of the A
<td><code>mozFullScreenElement</code></td>
<td><code>msFullscreenElement</code></td>
</tr>
<tr>
<th scope="row">
{{DOMxRef("Document.onfullscreenchange")}}
</th>
<td><code>onwebkitfullscreenchange</code></td>
<td><code>onmozfullscreenchange</code></td>
<td><code>onmsfullscreenchange</code></td>
</tr>
<tr>
<th scope="row">
{{DOMxRef("Document.onfullscreenerror")}}
</th>
<td><code>onwebkitfullscreenerror</code></td>
<td><code>onmozfullscreenerror</code></td>
<td><code>onmsfullscreenerror</code></td>
</tr>
<tr>
<th scope="row">{{DOMxRef("Document.exitFullscreen()")}}</th>
<td><code>webkitExitFullscreen()</code></td>
Expand Down
7 changes: 0 additions & 7 deletions files/en-us/web/api/fullscreen_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ _The Fullscreen API defines two events which can be used to detect when full-scr

> **Note:** These event handler properties are _not_ available as HTML content attributes. In other words, you cannot specify event handlers for {{Event("fullscreenchange")}} and {{Event("fullscreenerror")}} in the HTML content. They must be added by JavaScript code.

#### Event handlers on documents

- {{DOMxRef("Document.onfullscreenchange")}}
- : An event handler for the {{Event("fullscreenchange")}} event that's bubbled up to the {{DOMxRef("Document")}} when any {{DOMxRef("Element")}} in that document is placed into full-screen mode, or exits full-screen mode.
- {{DOMxRef("Document.onfullscreenerror")}}
- : An event handler for the {{Event("fullscreenerror")}} event that gets bubbled up to the {{DOMxRef("Document")}} when an error occurs while trying to enable or disable full-screen mode for any {{DOMxRef("Element")}} in that document.

#### Event handlers on elements

- {{DOMxRef("Element.onfullscreenchange")}}
Expand Down