Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
skyclouds2001 committed Sep 23, 2024
1 parent 3e7b55a commit 5d572f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions files/en-us/web/api/fullscreen_api/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ When fullscreen mode is successfully engaged, the document which contains the el

### When a fullscreen request fails

It's not guaranteed that you'll be able to switch into fullscreen mode. For example, {{HTMLElement("iframe")}} elements have the [`allowfullscreen`](/en-US/docs/Web/HTML/Element/iframe#allowfullscreen) attribute in order to opt-in to allowing their content to be displayed in fullscreen mode. In addition, certain kinds of content, such as windowed plug-ins, cannot be presented in fullscreen mode. Attempting to put an element which can't be displayed in fullscreen mode (or the parent or descendant of such an element) won't work. Instead, the element which requested fullscreen will receive a `mozfullscreenerror` event. When a fullscreen request fails, Firefox will log an error message to the Web Console explaining why the request failed. In Chrome and newer versions of Opera however, no such warning is generated.
It's not guaranteed that you'll be able to switch into fullscreen mode. For example, {{HTMLElement("iframe")}} elements have the [`allowfullscreen`](/en-US/docs/Web/HTML/Element/iframe#allowfullscreen) attribute in order to opt-in to allowing their content to be displayed in fullscreen mode. In addition, certain kinds of content, such as windowed plug-ins, cannot be presented in fullscreen mode. Attempting to put an element which can't be displayed in fullscreen mode (or the parent or descendant of such an element) won't work. Instead, the element which requested fullscreen will receive a `fullscreenerror` event. When a fullscreen request fails, Firefox will log an error message to the Web Console explaining why the request failed. In Chrome and newer versions of Opera however, no such warning is generated.

> [!NOTE]
> Fullscreen requests need to be called from within an event handler or otherwise they will be denied.
Expand Down Expand Up @@ -105,7 +105,7 @@ function toggleFullScreen() {
}
```

This starts by looking at the value of the `fullscreenElement` attribute on the {{DOMxRef("document")}}. If it's `null`, the document is currently in windowed mode, so we need to switch to fullscreen mode. Switching to fullscreen mode is done by calling {{DOMxRef("element.requestFullscreen()")}}.
This starts by looking at the value of the `fullscreenElement` attribute on the {{DOMxRef("document")}}. If it's `null`, the document is currently in windowed mode, so we need to switch to fullscreen mode. Switching to fullscreen mode is done by calling {{DOMxRef("Element.requestFullscreen()")}}.

If fullscreen mode is already active (`fullscreenElement` is non-`null`), we call {{DOMxRef("document.exitFullscreen()")}}.

Expand Down
7 changes: 6 additions & 1 deletion files/jsondata/GroupData.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,12 @@
"guides": ["/docs/Web/API/Fullscreen_API/Guide"],
"interfaces": [],
"methods": ["Document.exitFullscreen()", "Element.requestFullscreen()"],
"properties": ["Document.fullscreen", "Document.fullscreenElement"],
"properties": [
"Document.fullscreen",
"Document.fullscreenElement",
"Document.fullscreenEnabled",
"ShadowRoot.fullscreenElement"
],
"events": [
"Document: fullscreenchange",
"Document: fullscreenerror",
Expand Down

0 comments on commit 5d572f6

Please sign in to comment.