Play the class film fullscreen: requestFullscreen() inside your click or as the page opens, an Esc the viewer presses, and fullscreenchange: does your code’s…
Video players, image viewers, presentations, games and editor focus modes all use this. Knowing that fullscreen is per element, needs a user gesture, and can end through Esc without your code puts the call in the right place and keeps your UI honest.
Fullscreen is per element, needs a gesture, and is ended by the browser
requestFullscreen() is refused when called on onload or in setTimeout The browser only allows it with a user activation that is still warm (a click, a key, a touch a moment before). Without one its Promise rejects with a TypeError and fullscreenerror fires. Call it inside a click/keydown handler, before any long await.requestFullscreen() is a Promise It can be refused (no gesture, an iframe without allow="fullscreen", a user who says no). Use try { await … } catch or .catch(); otherwise the refusal becomes an unhandledrejection.fullscreenchange event and document.fullscreenElement, not from a manual flag.document.fullscreenElement points at div.layar, and the rest of the page hides behind it.fullscreenchange still comes, and the board writes "left through the browser".fullscreenerror fires.document.documentElement, play again Now the whole page fills the screen: the scene stays visible, and fullscreenElement is <html>.