Put browser full screen and refresh on button click (simulate F11) JavaScript

12,435

Solution 1

maybe this can help you example of full screen using the blog post Native Fullscreen JavaScript API (plus jQuery plugin)

Solution 2

This question is possibly a duplicate of a question you linked to. The latest cross-browser solution is:

function requestFullScreen(elt) {
    console.log("Requesting fullscreen for", elt);
    if (elt.requestFullscreen) {
        elt.requestFullscreen();
    } else if (elt.msRequestFullscreen) {
        elt.msRequestFullscreen();
    } else if (elt.mozRequestFullScreen) {
        elt.mozRequestFullScreen();
    } else if (elt.webkitRequestFullscreen) {
        elt.webkitRequestFullscreen();
    } else {
        console.error("Fullscreen not available");
    }
}

Please note that this is "experimental technology" as of this post. See this answer and this MDN page for more details.

Share:
12,435
Amila
Author by

Amila

Updated on June 19, 2022

Comments

  • Amila
    Amila about 2 years

    I went through more than 10 questions with same content but not to find a updated answer. (world of web is changing rapidly I guess). First thing is, is it possible to put current window full screen simulating F11 press on a user button click. also what is the best practice for doing it if I want the function to work in all major browsers (IE, FF, Chrome and Safari).

    How to make in Javascript full screen windows (stretching all over the screen)

    Simulate F11 with javascript

    onclick go full screen

    including above links I went through lot of questions but had no susses. Its really helpful if someone can come up with an idea. Thanks.

  • Amila
    Amila almost 11 years
    no, I want entire page full screen when user press the goTofullScreen Button.
  • mplungjan
    mplungjan almost 11 years
    See the link I added. Safari and Chrome supports that
  • Amila
    Amila almost 11 years
    Thanks, This also works for going fulls screen, but i want to refresh on full screen. as soon as I refresh it full screen is gone. any idea to get rid of that.
  • Amila
    Amila almost 7 years
    @Vixed, nope, had to stop refreshing. this is an old question. There might be a new solution now. Good luck finding that.