Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 253
Amila Avatar asked Oct 03 '22 08:10

Amila


2 Answers

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

like image 156
ZaoTaoBao Avatar answered Oct 12 '22 17:10

ZaoTaoBao


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.

like image 33
Luke Avatar answered Oct 12 '22 17:10

Luke