Properties with and without prefixes
-
The document.fullscreenElement
, requestFullscreen
and document.exitFullscreen
are native, but only newer browsers support it
The document.mozFullScreenElement
, mozRequestFullScreen
and document.exitFullscreen
are native to older browsers with Mozilla technology, such as out-of-date Firefox browsers (probably still supported for backwards compatibility), moz
is a used prefix for experimental features in Mozilla browsers or features that only exist in these browsers, CSS in Mozilla also uses -moz
as a prefix
-
document.webkitFullscreenElement
, webkitRequestFullscreen
, and document.mozCancelFullScreen
are native to outdated Chrome and Safari browsers (probably still supported for backward compatibility), webkit
is a prefix used for experimental features in Webkit browsers or features that only exist in these browsers, CSS in Blink and Webkit also uses -webkit
as a prefix
-
The document.msFullscreenElement
, msRequestFullscreen
and document.msExitFullscreen
are used by the only IE11 browser
The use of document.fullscreenElement
The properties document.fullscreenElement
, document.mozFullScreenElement
, document.webkitFullscreenElement
and document.msFullscreenElement
, return the element that is in fullscreen, if it does not have anything in fullscreen it will return null
, in case your code is being used for check if you have nothing in fullscreen to execute the code, then it will execute document.exitFullscreen
(or with prefixes)
The reason for using prefixes moz, ms, webkit
Today almost all browsers use only document.fullscreenElement
, the code you're using is what we call backward compatibility or reverse compatibility , it's a term often used in console but it is fully valid for almost anything, the purpose of backward compatibility is to support older technologies, perhaps the user has an older browser, or a computer that does not support newer browsers.