I am trying to find out whether Safari is in fullscreen mode using Javascript. Chrome and Mozilla both use vendor-prefixed versions of document.fullscreenElement:
isFullscreen = function() {
return document.fullscreenElement
|| document.webkitFullscreenElement
|| document.mozFullScreenElement;
}
However, this doesn't work on Safari 5.1.7 -- there is no "webkitFullscreenElement" or similar property on document.
Does anyone know if there's a way to tell whether Safari is in fullscreen mode?
It's pretty hard to find this one, but the property you are looking for is:
document.webkitCurrentFullScreenElement
As you can see it doesn't follow standard, not even close, at all.
Also worth to mention as it is related: the property to check if fullscreen mode is supported is also hard to find (I still haven't...) so to check for support I do:
if (typeof document.webkitCurrentFullScreenElement !== 'undefined') ...
as the property will be null (or the fullscreen element).