Element: fullscreenerror event

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Fullscreen API")}}

The **fullscreenerror** event is fired when the browser cannot switch to fullscreen mode.

As with the [fullscreenchange event](/en-US/docs/Web/API/Element/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 fullscreen mode might fail, see the guide to the Fullscreen API.

This event is not cancelable.

Syntax

Use the event name in {{domxref("EventTarget/addEventListener", "addEventListener()")}}:

js-nolint
addEventListener("fullscreenerror", (event) => { })

Alternatively, assign to the event handler property of the interface:

js-nolint
onfullscreenerror = (event) => { }

Event type

A generic {{domxref("Event")}}.

Examples

js
const requestor = document.querySelector("div");

function handleError(event) {
  console.error("an error occurred changing into fullscreen");
  console.log(event);
}

requestor.addEventListener("fullscreenerror", handleError);
// Or (but note that this replaces other event listeners
// added using onfullscreenerror, if any)
requestor.onfullscreenerror = handleError;

requestor.requestFullscreen();

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also