Search code examples
javascriptgoogle-chromefullscreen

Chrome Fullscreen API


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?


Solution

  • 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);
    });