Nossos voluntários ainda não traduziram este artigo para o Português (do Brasil). Junte-se a nós e ajude-nos a fazer o trabalho!
Você também pode ler o artigo em 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 an HTML or the <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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 15
Prefixed
Full support 15
Prefixed
Prefixed Requires the vendor prefix: webkit
Edge Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
Firefox Full support 64
Full support 64
Full support 47
Disabled
Disabled From version 47: this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Full support 9
Notes Alternate Name
Notes Before Firefox 44, Firefox 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.
Alternate Name Uses the non-standard name: mozRequestFullScreen
IE Full support 11
Prefixed
Full support 11
Prefixed
Prefixed Requires the vendor prefix: ms
Opera Full support 15
Prefixed
Full support 15
Prefixed
Prefixed Requires the vendor prefix: webkit
No support 12 — 15
Prefixed
Prefixed Requires the vendor prefix: o
Safari Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
WebView Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
Chrome Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
Edge Mobile Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
Firefox Android Full support 64
Full support 64
Full support 47
Disabled
Disabled From version 47: this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
Full support 9
Notes Alternate Name
Notes Before Firefox 44, Firefox 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.
Alternate Name Uses the non-standard name: mozRequestFullScreen
Opera Android Full support 14
Prefixed
Full support 14
Prefixed
Prefixed Requires the vendor prefix: webkit
No support 12 — 14
Prefixed
Prefixed Requires the vendor prefix: o
Safari iOS Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
Samsung Internet Android Full support Yes
Prefixed
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
Returns a PromiseChrome No support NoEdge No support NoFirefox Full support 64IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android Full support 64Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Uses a non-standard name.
Uses a non-standard name.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also

Etiquetas do documento e colaboradores

Última atualização por: ExE-Boss,