Nasi wolontariusze nie przetłumaczyli jeszcze tego artykułu na język Polski. Dołącz do nas i pomóż go przetłumaczyć!
Można także przeczytać artykuł w języku: English (US).

The Element.requestFullscreen() method issues an asynchronous request to make the element be displayed full-screen.

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 document 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 document receives a fullscreenerror event instead.

This method must be invoked from a user interaction or a device orientation change, else it will fail.

Only elements which are in the HTML namespace (that is, elements which are standard HTML), plus the <svg> and <math> elements, which are located in the top-level document or in an <iframe> with the allowfullscreen attribute can be displayed full-screen. This means that elements inside a <frame> or an <object> can't.

Syntax

var Promise = Element.requestFullscreen();

Parameters

None.

Return value

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

Exceptions

The promise may reject with an exception if the request for full screen fails. Possible exceptions include:

  • The element's document is not in a state where it can go full screen (for instance, it has no defaultView).
  • The element is not a HTML, SVG or Math element.
  • Full screen is not allowed (e.g. not initiated from a user action) or not supported.
TypeError
This may occur in one of the following situations:

Example

Before calling requestFullscreen(), set up event handlers for the fullscreenchange and fullscreenerror events, so you know when you've successfully switched into full-screen mode (or when permission to do so has been denied).

tbd

Specifications

Specification Status Comment
Fullscreen API
The definition of 'Element.requestFullscreen()' in that specification.
Living Standard Initial definition

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox Internet Explorer Opera Safari
Basic support (Yes)webkit1 (Yes)3 9 (9) as mozRequestFullScreen2
47 (47) (behind full-screen-api.unprefix.enabled)
64 (64)
11ms3 ? ?
Returns a Promise No support No support 64 (64) No support No support No support
Feature Chrome Android Edge Mobile Firefox Android Opera Android Safari iOS
Basic support (Yes)webkit1 (Yes)3 9.0 (9) as mozRequestFullScreen2
47.0 (47) (behind full-screen-api.unprefix.enabled)
64.0 (64)
? ?
Returns a Promise No support No support No support 64.0 (64) No support

1. Supported as webkitRequestFullscreen.

2. Supported as mozRequestFullScreen (notice the capital S for Screen). Before Firefox 44, Gecko incorrectly allowed elements inside a <frame> or an <object> 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> with the allowfullscreen attribute can be displayed fullscreen.

3. See documentation on MSDN.

See also