F11 mode in browser

Asked

Viewed 870 times

2

Is there any way to make the site, when it is automatically loaded, stay in full screen as when we press F11, in any browser?

3 answers

4


Just use js to load the page to click the button.

function toggleFullScreen(elem) {
        // ## The below if statement seems to work better ## if ((document.fullScreenElement && document.fullScreenElement !== null) || (document.msfullscreenElement && document.msfullscreenElement !== null) || (!document.mozFullScreen && !document.webkitIsFullScreen)) {
        if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
            if (elem.requestFullScreen) {
                elem.requestFullScreen();
            } else if (elem.mozRequestFullScreen) {
                elem.mozRequestFullScreen();
            } else if (elem.webkitRequestFullScreen) {
                elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
            } else if (elem.msRequestFullscreen) {
                elem.msRequestFullscreen();
            }
        } else {
            if (document.cancelFullScreen) {
                document.cancelFullScreen();
            } else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
            } else if (document.webkitCancelFullScreen) {
                document.webkitCancelFullScreen();
            } else if (document.msExitFullscreen) {
                document.msExitFullscreen();
            }
        }
    }

HTML

<input type="button" value="click to toggle fullscreen" onclick="toggleFullScreen(document.body)">

CSS

*:fullscreen
*:-ms-fullscreen,
*:-webkit-full-screen,
*:-moz-full-screen {
   overflow: auto !important;
}

Example of https://jsfiddle.net/a3rwnvca/2/

3

inserir a descrição da imagem aqui

Fortunately this is not possible without a previous user interaction (e.g.. click, keypress, keydown). It is a native browser lock that prevents page code from manipulating window behavior.

You can use the code provided in the other responses, but you will have to create, for example, a button for the user to click on it.

2

There is a Fullscreen Api:

https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API

var elem = document.body;
if (elem.requestFullscreen) {
  elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
  elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
  elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
  elem.webkitRequestFullscreen();
}

Browser other questions tagged

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