Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onload website should display fullscreen

hi i am working on a website using HTML CSS JavaScript and jQuery. I wanted to display website fullscreen(like when we click F11) onload. I am able to enter fullscreen using onclick even. But with onload event fullscreen script is not working. When i load a site it should display in fullscreen. please help. Here is my code : here is my HTML code:

<html id="player3">
  <body onload="goFullscreen('player');">
  </body>
</html>

Here is my js

 function goFullscreen() {
 var element = document.getElementById("player3");
if (element.mozRequestFullScreen) {
       element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
  element.webkitRequestFullScreen();}
   }
like image 821
Nagu Avatar asked Jun 03 '16 08:06

Nagu


Video Answer


1 Answers

Browsers doesn't allow sites to load in fullscreen mode without user interaction. You will get the following error message

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

To Handle this change your UX to make the user interact with your site to go fullscreen mode.

like image 68
Ajanthan Mani Avatar answered Oct 15 '22 13:10

Ajanthan Mani