Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to initialize fullscreen without user interaction

Hi i'm beginner and i want to create a web-app and needs help in fullscreen when page is Load... without user interaction

I have something like this at the click function works correctly... but i want to load function at the start page

addEventListener("click", function() 
    {
        var el = document.documentElement , rfs = el.requestFullScreen ||
        el.webkitRequestFullScreen || el.mozRequestFullScreen ;
        rfs.call(el);
    });

Someone help me :)

Thank you!

like image 356
siasty Avatar asked Jun 15 '15 09:06

siasty


1 Answers

That is not possible.

I ran the following snippet in my browser console:

var e = document.getElementById('answers');
(e.webkitRequestFullScreen || e.mozRequestFullScreen).apply(e);

Chrome told me:

Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture.

Firefox told me:

Request for full-screen was denied because Element.mozRequestFullScreen() was not called from inside a short running user-generated event handler.

That is a restriction put in place to prevent abuse, similar to that on window.open (see this or this question for example).

like image 126
Siguza Avatar answered Oct 25 '22 12:10

Siguza