How to Open a Web Page Automatically in Full Screen Mode

How to open a web page automatically in full screen mode

For Chrome via Chrome Fullscreen API

Note that for (Chrome) security reasons it cannot be called or executed automatically, there must be an interaction from the user first. (Such as button click, keydown/keypress etc.)

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

Javascript Fullscreen API as demo'd by David Walsh that seems to be a cross browser solution

// Find the right method, call on correct element
function launchFullScreen(element) {
if(element.requestFullScreen) {
element.requestFullScreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}

// Launch fullscreen for browsers that support it!
launchFullScreen(document.documentElement); // the whole page
launchFullScreen(document.getElementById("videoElement")); // any individual element

Enter full screen automatically by inserting script in a webpage using requestly

TLDR; This is not possible to auto-trigger full-screen mode using Script Insertion. It has to be based on user Interaction.

As per requestFullscreen MDN documentation

This method must be called while responding to user interaction or a device orientation change; otherwise, it will fail.

I tried triggering an automatic click on a button dynamically inserted into the page but we get the same error.

Sample Image

Here's the Insert Script Rule I created in Requestly

Sample Image

How to make the window full screen with Javascript (stretching all over the screen)

This is as close as you can get to full screen in JavaScript:

<script type="text/javascript">
window.onload = maxWindow;

function maxWindow() {
window.moveTo(0, 0);

if (document.all) {
top.window.resizeTo(screen.availWidth, screen.availHeight);
}

else if (document.layers || document.getElementById) {
if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
}
</script>


Related Topics



Leave a reply



Submit