i am working with the javascript to display my div to full screen . i have a function which call on button click and my screen turns into full screen mode but i want the full screen on page load.
what i have tried is
function togglescreen(){
var element = document.getElementById("video-container");
element.requestFullscreen();
}
<button id="fullscreenBtn" onclick="togglescreen()">Full Screen</button>
<div id="video-container" width="1000" height="500"></div>
it works perfectly but i need full screen into my page load. i also tried
document.getelementbyId("fullscreenBtn").click();
but it's also not working.
It's not possible, it needs to be triggered by the device or user input. It'd be easily abused otherwise.
https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen
Note: This method must be called while responding to a user interaction or a device orientation change; otherwise it will fail.