1
Do I need to fire the event (F11) from the keyboard using javascript ? In order to trigger fullscreen (full screen) as soon as a certain web app is preloaded.
1
Do I need to fire the event (F11) from the keyboard using javascript ? In order to trigger fullscreen (full screen) as soon as a certain web app is preloaded.
1
It is not possible to do this in modern browsers, other than within 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>
<button id="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>
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
great example Miguel +1
– Guilherme Nascimento