Randomblue Randomblue - 4 months ago 29
Javascript Question

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?

Answer

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
    ;
    rfs.call(el);
});
Comments