2
I searched a little about the same on google and most people talk to use
position: absolute;
z-index:9999;
width:100%;
height:100%;
top:0;
left:0;
However the code above only works to put in fullscreen inside the window, and that’s not what I want, I want to use real Fullscreen, the whole user screen and then I found the code below:
if (!document.fullscreenElement &&
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) {
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
This one works perfectly, but puts the whole document in full screen, and I just want a specific div in fullscreen, how can I do this?
They pointed out that this question is the same as this, but it is not, the solutions presented in it are the same that I am asking here to try to adapt to my use. Is there any way to enable full screen browser with Javascript?
Already tried to exchange Document for div id?
– Danilo Pádua
Yes I tried putting so $(div) and getting it by getElementById but it didn’t work
– Leo Letto
You want the element in fullscreen (the one that closes the whole browser, including the address bar (F11)) or just overwrites the other elements of the site (such as Sopt’s snnipet)?
– Randrade
@Randrade yes I want to put the element in fullscreen, 100% user monitor
– Leo Letto
Your question already has an answer in this question. See an example of a working answer in Jsfiddle.
– Randrade
@Randrade in my question I made clear that this code puts the whole document in fullscreen, I want to put only one element in fullscreen...
– Leo Letto
@You’re right, my fault. I removed the vote
– Randrade
@Leoletto if you read the answer to the end and tell me that you do not speak fullscreen there I will believe, but I recommend you read my answer specifically please http://answall.com/a/168938/3635
– Guilherme Nascimento