Chrome Fullscreen API

Randomblue picture Randomblue · Oct 20, 2011 · Viewed 102.4k times · Source

According to this article Google Chrome 15 has a fullscreen JavaScript API.

I have tried to make it work but failed. I have also searched for official documentation in vain.

What does the fullscreen JavaScript API look like?

Answer

Eli Grey picture Eli Grey · Oct 28, 2011

The API only works during user interaction, so it cannot be used maliciously. Try the following code:

addEventListener("click", function() {
    var el = document.documentElement,
      rfs = el.requestFullscreen
        || el.webkitRequestFullScreen
        || el.mozRequestFullScreen
        || el.msRequestFullscreen 
    ;

    rfs.call(el);
});