FullscreenAPI-Polyfill

This project seeks to normalize the Fullscreen API across the different browsers so that the user can use the standardized API calls in their code rather than having to guess at all the different spellings and prefixes. It is important to note that this polyfill only works in browsers that support some form of the Fullscreen API.

API

Element.requestFullscreen()

Used to request that an element enter fullscreen. Upon success, the fullscreenchange event will be fired on the document object. On failure, the fullscreenerror event will be fired on the document object.

document.exitFullscreen()

Only one element is allowed to be fullscreen at any given time. To exit fullscreen mode, call document.exitFullscreen().

document.fullscreenEnabled

Returns true if document has the ability to display elements fullscreen and fullscreen is supported, or false otherwise.

document.fullscreenElement

Returns the element that is displayed in fullscreen, or null if there are no elements currently displayed in fullscreen.

allowfullscreen

This attribute only affects <iframe>s. When set to true the iframe document will not be allowed to request that an element enterfullscreen. If omitted or set to false, the iframe document will be allowed to request that an element enter fullscreen.

Events

fullscreenchange

Everytime an Element successfully enters fullscreen or the document exits fullscreen, a fullscreenchange event will be fired. Use the document.fullscreenElement property in conjunction with the fullscreenchange event to determine whether the event was fired in response to an element entering fullscreen or the document exiting fullscreen.

fullscreenerror

The fullscreenerror event is fired when an attempt element's attempt to enter fullscreen has failed for some reason.