Full screen when loading the page

Asked

Viewed 1,520 times

0

How to give a Full Screen on a page as soon as the browser finishes loading it, but that works also in the browsers of the Android OS? I’ve used the famous load to fire the event after loading the window.

 $(window).load("on", function (){
     //...code...
 });

But, I did not succeed even in Chrome on my PC. The part of Full Screen managed to solve using the plugin fullscreen.js. However, I can’t make it work once the page finishes loading. Follow in Fiddle as I have implemented so far, firing the full screen by clicking on the text that is in a tag H1. I also use jQuery in the project, but what’s in Fiddle is just a test. The project I’m going to use this in is much bigger.

  • 2

    Are you sure it’s not $(document).ready(function(){}); or $(function(){});?

  • I’ve tested all these.

  • 1

    That I know fullscreen requires user intervention, the browser does not allow you to fire without a click or some other type of interaction.

  • @Bfavaretto has no way to force this?

  • 1

    If the browser let you do this, a website could fill your advertising screen, for example. Nasty. See: http://answall.com/questions/1855/existe-alguma-maneira-de-ativar-a-tela-cheia-browser-com-javascript (duplicate?)

1 answer

1

You can try starting using the syntax below:

$(window).on('load', function () { ... });

I would also try to put one setTimeout as security. After the page loads, it executes something after 1 second. Example:

$(window).load(function () {

   setTimeout(function () {
      telaCheia();
   }, 1000);

});

function telaCheia() {
  if (screenfull.enabled) {
    screenfull.request();
  }
  ...
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.