Element: requestFullscreen() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The Element.requestFullscreen() method issues an asynchronous request to make the element be displayed in fullscreen mode.

It's not guaranteed that the element will be put into full screen mode. If permission to enter full screen mode is granted, the returned Promise will resolve and the element will receive a fullscreenchange event to let it know that it's now in full screen mode. If permission is denied, the promise is rejected and the element receives a fullscreenerror event instead. If the element has been detached from the original document, then the document receives these events instead.

Syntax

js
requestFullscreen()
requestFullscreen(options)

Parameters

options Optional

An object that controls the behavior of the transition to fullscreen mode. The available options are:

Controls whether or not to show navigation UI while the element is in fullscreen mode. The default value is "auto", which indicates that the browser should decide what to do.

"hide"

The browser's navigation interface will be hidden and the entire dimensions of the screen will be allocated to the display of the element.

"show"

The browser will present page navigation controls and possibly other user interface; the dimensions of the element (and the perceived size of the screen) will be clamped to leave room for this user interface.

"auto"

The browser will choose which of the above settings to apply. This is the default value.

screen Optional

Specifies on which screen you want to put the element in fullscreen mode. This takes a ScreenDetailed object as a value, representing the chosen screen.

Return value

A Promise which is resolved with a value of undefined when the transition to full screen is complete.

Exceptions

Rather than throw a traditional exception, the requestFullscreen() procedure announces error conditions by rejecting the Promise it has returned. The rejection handler receives one of the following exception values:

TypeError

The TypeError exception may be delivered in any of the following situations:

  • The document containing the element isn't fully active; that is, it's not the current active document.
  • The element is not contained by a document.
  • The element is not permitted to use the fullscreen feature, either because of Permissions Policy configuration or other access control features.
  • The element and its document are the same node.
  • The element is a popover that is already being shown via HTMLElement.showPopover().

Security

Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.

Usage notes

Compatible elements

An element that you wish to place into fullscreen mode has to meet a small number of simple requirements:

  • It must be one of the standard HTML elements or <svg> or <math>.
  • It is not a <dialog> element.
  • It must either be located within the top-level document or in an <iframe> which has the allowfullscreen attribute applied to it.

Additionally, any set Permissions Policies must allow the use of this feature.

Detecting fullscreen activation

You can determine whether or not your attempt to switch to fullscreen mode is successful by using the Promise returned by requestFullscreen(), as seen in the examples below.

To learn when other code has toggled fullscreen mode on and off, you should establish listeners for the fullscreenchange event on the Document. It's also important to listen for fullscreenchange to be aware when, for example, the user manually toggles fullscreen mode, or when the user switches applications, causing your application to temporarily exit fullscreen mode.

Examples

Requesting fullscreen mode

This example toggles the <video> element in and out of fullscreen mode when the Enter or Shift + F keys are pressed. The script checks whether the document is currently in fullscreen using document.fullscreenElement. If the document is in fullscreen, it calls document.exitFullscreen() to exit. Otherwise, it calls requestFullscreen() on the <video> element:

js
const video = document.querySelector("video");

document.addEventListener("keydown", (event) => {
  // Note that "F" is case-sensitive (uppercase):
  if (event.key === "Enter" || event.key === "F") {
    // Check if we're in fullscreen mode
    if (document.fullscreenElement) {
      document.exitFullscreen();
      return;
    }
    // Otherwise enter fullscreen mode
    video.requestFullscreen().catch((err) => {
      console.error(`Error enabling fullscreen: ${err.message}`);
    });
  }
});
html
<p>
  The video element below shows a time-lapse of a flower blooming. You can
  toggle fullscreen on and off using <kbd>Enter</kbd> or <kbd>Shift</kbd> +
  <kbd>F</kbd> (uppercase "F"). The embedded document needs to have
  <a
    href="https://developer.mozilla.org/en-US/docs/Web/API/Element/focus_event">
    focus
  </a>
  for the example to work.
</p>

<video controls loop src="/shared-assets/videos/flower.mp4" width="420"></video>

Using navigationUI

In this example, the entire document is placed into fullscreen mode by calling requestFullscreen() on the document's Document.documentElement, which is the document's root <html> element.

js
let elem = document.documentElement;

elem
  .requestFullscreen({ navigationUI: "show" })
  .then(() => {})
  .catch((err) => {
    alert(
      `An error occurred while trying to switch into fullscreen mode: ${err.message} (${err.name})`,
    );
  });

The promise's resolve handler does nothing, but if the promise is rejected, an error message is displayed by calling alert().

Using the screen option

If you wanted to make the element fullscreen on the primary OS screen, you could use code like the following:

js
try {
  const primaryScreen = (await getScreenDetails()).screens.find(
    (screen) => screen.isPrimary,
  );
  await document.body.requestFullscreen({ screen: primaryScreen });
} catch (err) {
  console.error(err.name, err.message);
}

The Window.getScreenDetails() method is used to retrieve the ScreenDetails object for the current device, which contains ScreenDetailed objects representing the different available screens.

Specifications

Specification
Fullscreen API
# ref-for-dom-element-requestfullscreen①

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
requestFullscreen
Chrome – Full support
Chrome 15 (Release date: 2011-10-25)
prefix
prefix Implemented with the vendor prefix: webkit
Chrome – Full support
Chrome 71 (Release date: 2018-12-04)
footnote Full support
Edge – No support
Edge 12 – 13 (Release date: 2015-07-29)
footnote Removed in 14 and later
Edge – Full support
Edge 12 (Release date: 2015-07-29)
prefix
prefix Implemented with the vendor prefix: webkit
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 9 (Release date: 2011-12-20)
footnote , altname
altname Alternate name: mozRequestFullScreen
footnote Before Firefox 44, Firefox incorrectly allowed elements inside a <frame> or <object> element to request, and to be granted, fullscreen. In Firefox 44 and onwards this has been fixed: only elements in the top-level document or in an <iframe> element with the allowfullscreen attribute can be displayed fullscreen.
Firefox – Full support
Firefox 64 (Release date: 2018-12-11)
footnote Full support
Opera – No support
Opera 12.1 – 12.1 (Release date: 2012-11-20)
unknown Support unknown
Opera – Full support
Opera 15 (Release date: 2013-07-02)
prefix
prefix Implemented with the vendor prefix: webkit
Opera – Full support
Opera 58 (Release date: 2019-01-23)
footnote Full support
Safari – Full support
Safari 5.1 (Release date: 2011-07-20)
prefix
prefix Implemented with the vendor prefix: webkit
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
prefix
prefix Implemented with the vendor prefix: webkit
Chrome Android – Full support
Chrome Android 71 (Release date: 2018-12-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 9 (Release date: 2011-12-21)
footnote , altname
altname Alternate name: mozRequestFullScreen
footnote Before Firefox for Android 44, Firefox for Android incorrectly allowed elements inside a <frame> or <object> element to request, and to be granted, fullscreen. In Firefox for Android 44 and onwards this has been fixed: only elements in the top-level document or in an <iframe> element with the allowfullscreen attribute can be displayed fullscreen.
Firefox for Android – Full support
Firefox for Android 64 (Release date: 2018-12-11)
footnote Full support
Opera Android – No support
Opera Android 12.1 – 12.1 (Release date: 2012-10-09)
unknown Support unknown
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
prefix
prefix Implemented with the vendor prefix: webkit
Opera Android – Full support
Opera Android 50 (Release date: 2019-02-18)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 12 (Release date: 2018-09-17)
prefix
footnote Partial support
prefix Implemented with the vendor prefix: webkit
footnote Only available on iPad, not on iPhone. Shows an overlay button which can not be disabled.
Safari on iOS – Partial support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Partial support
footnote Only available on iPad, not on iPhone.
footnote Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
prefix
prefix Implemented with the vendor prefix: webkit
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
prefix
prefix Implemented with the vendor prefix: webkit
WebView Android – Full support
WebView Android 71 (Release date: 2018-12-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
options parameter
Chrome – Full support
Chrome 71 (Release date: 2018-12-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Preview support
Firefox 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera – Full support
Opera 58 (Release date: 2019-01-23)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 71 (Release date: 2018-12-04)
footnote Full support
Firefox for Android – Preview support
Firefox for Android 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera Android – Full support
Opera Android 50 (Release date: 2019-02-18)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 71 (Release date: 2018-12-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
keyboardLock option
Non-standard
Chrome – No support
Chrome
footnote
footnote See bug 505427218
Edge – No support
Edge
footnote
footnote See bug 505427218
Firefox – Preview support
Firefox 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera – No support
Opera
footnote
footnote See bug 505427218
Safari – Full support
Safari 26.4 (Release date: 2026-03-24)
footnote Full support
Chrome Android – No support
Chrome Android
footnote
footnote See bug 505427218
Firefox for Android – Preview support
Firefox for Android 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera Android – No support
Opera Android
footnote
footnote See bug 505427218
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote
footnote See bug 505427218
WebView Android – No support
WebView Android
footnote
footnote See bug 505427218
WebView on iOS – No support
WebView on iOS
footnote No support
navigationUI option
Chrome – Full support
Chrome 71 (Release date: 2018-12-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 58 (Release date: 2019-01-23)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 71 (Release date: 2018-12-04)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 50 (Release date: 2019-02-18)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 71 (Release date: 2018-12-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
screen option
Experimental
Chrome – Full support
Chrome 100 (Release date: 2022-03-29)
footnote Full support
Edge – Full support
Edge 100 (Release date: 2022-04-01)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 86 (Release date: 2022-04-20)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
Returns a Promise
Chrome – Full support
Chrome 71 (Release date: 2018-12-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 64 (Release date: 2018-12-11)
footnote Full support
Opera – Full support
Opera 58 (Release date: 2019-01-23)
footnote Full support
Safari – Full support
Safari 16.4 (Release date: 2023-03-27)
footnote Full support
Chrome Android – Full support
Chrome Android 71 (Release date: 2018-12-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 64 (Release date: 2018-12-11)
footnote Full support
Opera Android – Full support
Opera Android 50 (Release date: 2019-02-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 16.4 (Release date: 2023-03-27)
footnote Full support
Samsung Internet – Full support
Samsung Internet 10 (Release date: 2019-08-22)
footnote Full support
WebView Android – Full support
WebView Android 71 (Release date: 2018-12-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
See implementation notes.
Uses a non-standard name
Requires a vendor prefix or different name for use.
Has more compatibility info.

See also