Do I need to trigger the keyboard event (F11) through javascript? In order to trigger the fullscreen (full screen) once a certain web app is preloaded.
Do I need to trigger the keyboard event (F11) through javascript? In order to trigger the fullscreen (full screen) once a certain web app is preloaded.
This is not possible in modern browsers other than a keyboard or mouse event.
In this case you can use this code to put it in full screen:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><buttonid="btn">Full screen.</button>
<div id="full" style="background-color: green;">Tela cheia</div>
<script>
$(function() {
function requestFullScreen(element) {
// Supports most browsers and their versions.
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;
if (requestMethod) { // Native full screen.
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
var elem = $("#full")[0]; // Make the body go full screen.
$("#btn").click(function() {
requestFullScreen(elem);
});
});
</script>