Reputation: 282
I'm trying to toggle chrome to full screen automatically, but it does not work, here is the sample code
<html>
<script src="jquery-1.9.1.min.js"></script>
<div>Full Screen Test</div>
<input id="fullScreentButton" type="button" value="toggle" onclick="enterFullScreen()">
<script type="text/javascript">
//enter the fullscreen on click, works.
function enterFullScreen(){
var element = document.getElementsByTagName('body')[0];
element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
function enterFullScreenInJquery(){
$('#fullScreentButton').trigger('click');
}
//enter the fullscreen on startup, does not work
enterFullScreenInJquery();
</script>
If I click the button, it works, how come the jquery one does not work?
Upvotes: 0
Views: 218
Reputation: 17795
The fullscreen JavaScript API only works during user interaction, so it cannot be used maliciously.
Upvotes: 3