0

I want to make the entire document fullscreen after loading:

<script type="text/javascript">
        function launchIntoFullscreen(element) {
          if (element.requestFullscreen) {
            element.requestFullscreen();
          } else if(element.mozRequestFullScreen) {
            element.mozRequestFullScreen();
          } else if(element.webkitRequestFullscreen) {
            element.webkitRequestFullscreen();
          } else if(element.msRequestFullscreen) {
            element.msRequestFullscreen();
          }
        }

        $(document).ready(function() {
            launchIntoFullscreen(document.documentElement);
        });
</script>

At runtime the document is not fullscreen; when I inspected the document the console displayed this:

The access to the full screen application was refused because Element.mozRequestFullScreen() was not called within a user-generated event handler

It said that there must be an event manager which should be generated and from which to call the function. So how do I create this event manager? And how do I call the function from it?

pheromix
  • 18,213
  • 29
  • 88
  • 158
  • 3
    You cannot go into full-screen mode yourself. As the error message states, the full screen request must be part of handling of a user event such as a click. This is a security feature to prevent rogue applications from putting themselves into full-screen mode. The error message is a little bit confusing. Try issuing your request from inside a click handler. –  Aug 16 '15 at 13:07
  • but I want it to happen on page loading , not on event such as click ! – pheromix Aug 16 '15 at 13:09
  • 1
    You cannot do that. That error means that the browser will only allow that to happen if it thinks that the user has explicitly clicked on something to make it happen. That means you cannot force full-screen from a "ready" or "load" handler, or anything else that's not related to user interaction. – Pointy Aug 16 '15 at 13:25
  • 1
    @pheromix: Why? It's unexpected behavior. I, as a user, don't appreciate things done to my screen real-estate without me agreeing first. That applied to full screen, mouse lock, window resize, or anything else. – Madara's Ghost Aug 16 '15 at 13:46
  • yes , but I want my application to be more user-friendly looking , I dont want user to be bored seeing the browser's address bar and so on , I want user to see just the app , I want the app to look like a Windows8 one :) I am using MetroUI CSS. – pheromix Aug 16 '15 at 13:49
  • there is nothing you can do. – Daniel A. White Aug 16 '15 at 14:13
  • http://stackoverflow.com/questions/9454125/javascript-request-fullscreen-is-unreliable?rq=1 – Daniel A. White Aug 16 '15 at 14:14

0 Answers0