The Fullscreen API is fairly new with growing support but the implementation varies across browsers. Screenfull.js is a simple script from Sindre Sorhus to change that, changing:

document.fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.documentElement.webkitRequestFullScreen;

function requestFullscreen( element ) {
  if ( element.requestFullscreen ) {
    element.requestFullscreen();
  } else if ( element.mozRequestFullScreen ) {
    element.mozRequestFullScreen();
  } else if ( element.webkitRequestFullScreen ) {
    element.webkitRequestFullScreen( Element.ALLOW_KEYBOARD_INPUT );
  }
}

if ( document.fullscreenEnabled ) {
  requestFullscreen( document.documentElement );
}

to

if ( screenfull ) screenfull.request();

The source is on GitHub.


Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.