Full Screen API embiggens the lowliest of web apps
January 11th, 2012Please forgive the Simpsons reference in the title, but let’s face it, browsers eat up an enormous amount of screen real estate with menu bars, super bars, status bars, toolbars, scrollbars. And that’s all before you get to the white space and toolbars and menus your own app requires.
Sure, you can press F11 today in pretty much every browser and achieve that end, but how many of us actually do that? If we’re the power users and we don’t do that, what hope do we have for our users?
The Full Screen API will make it easy to do automatically. Better still, pre-release versions of this API are already supported in Firefox 9 and Chrome 15 (though disabled by default in Firefox 9).
To get you started, the Mozilla Developer Network has released its own guide to the interface.
In brief, there are a few key requirements:
- The calling object for
requestFullScreen()must be a DOM node - The DOM node may not be the child or parent of a plugin
- If the DOM node is an IFRAME (or is the parent or child of one), the IFRAME must have an
allowfullscreen="true"attribute
So what does real-world code look like? Let’s take a look at Mozilla’s own example:
function toggleFullScreen() { if ((document.fullScreenElement && document.fullScreenElement !== null) || // alternative standard method (!document.mozFullScreen && !document.webkitIsFullScreen) { // current working methods if (videoElement.requestFullScreen) { videoElement.requestFullScreen(); } else if (elem.mozRequestFullScreen) { videoElement.mozRequestFullScreen(); } else if (elem.webkitRequestFullScreen) { videoElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); } } else { if (document.cancelFullScreen) { document.cancelFullScreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } } }
As you can see, the naming conventions aren’t quite there yet. Further, neither Firefox nor Chrome quite apply the CSS expectations of the developing standard.
When the calls fire successfully, either fullscreenchange, mozfullscreenchange or webkitfullscreenchange events will fire. Likewise, when it fails, either fullscreenerror, mozfullscreenerror or webkitfullscreenerror events fire.
Note also that in Firefox 9, you cannot use a form in fullscreen mode; pressing any key inside of an input seems to take you out of Full Screen mode. The browser provides no instructions for exiting fullscreen mode, so you will need to provide them yourself.
Confusingly, the ALLOW_KEYBOARD_INPUT parameter in the webkitRequestFullScreen() call seems to block the keystroke handler in the MDN sample, though forms once again work. It also provides instructions for exiting Full Screen mode, though it neglects to mention that Esc will do it as well, instead referring to Command + Shift + F on my Mac.
Still, Firefox 10 is expected to support the API out of the box, so we can start to see the development of true browser application environments. The possibilities for kiosk environments are also exciting.


