-1
I have this Pod, and I wish it to be invisible:
<input type="button" id="invisivel" value="" style="visibility: hidden;" onclick="toggleFullScreen()">
I would like when the page pressed that button to be automatically clicked.
I have this script
, but it doesn’t work:
window.setTimeout(function(){
document.getElementById("invisivel").click();
}, 2000);
Script of toggleFullScreen
:
function toggleFullScreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}
From what I understand he clicks one click after 2 seconds, unfortunately it is not working. I would like when you press the page the button to be automatically clicked.
The button is already invisible when loading the page, what happens when executing the click event, is the execution of the function
toggleFullScreen()
, that you did not show in the content of the question.– Benilson
Exactly that, because perform the function
toggleFullScreen
is working perfectly, my question is: simulate the automatic click of thisbutton
when loading the page.– Expresso 1002
@bfavaretto he said automatically, it assumes that he wants the fullscreen to be activated automatically, which is impossible and I’m also sure that would be annoying to the end user, as I replied in https://answall.com/a/306227/3635 ... I switched the dups
– Guilherme Nascimento
"index.html:19 Failed to execute 'requestFullscreen' on 'Element': API can only be initiated by a user Gesture." Google Chrome shows this on the console.
– Benilson
@Guilherme ok, this dup is even better
– bfavaretto
@Benilson translating the phrase, what the browser said was: "This API can only be initiated by a user gesture", ie only real user interactions work, simulate is impossible, the browser knows the difference, as I explained in my reply (linked above)
– Guilherme Nascimento
@Guilhermenascimento yes, I’m used to English, but sometimes I forget that others may not be, thank you for translating.
– Benilson
"mozRequestFullScreen() is obsolete. index.html:17:49 The full screen request was denied because Element.requestFullscreen() was not called from a short duration Event Handler created by a user." Firefox console, this already came in English.
– Benilson