Reputation: 377
I am trying to load a page on full screen mode the code below works but demands a click in the page i would like to do this on page load any help will be appreciate it!
code
<!-- full screen mode-->
<script type="text/javascript">
function launchIntoFullscreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
</script>
calling function
<script type="text/javascript">
$(document).ready(function () {
var myEl = document.getElementById('theBody');
myEl.addEventListener('click', function () {
launchIntoFullscreen(document.getElementById("theBody"));
}, false);
});
</script>
Upvotes: 3
Views: 1713
Reputation: 8181
This is an untested version. Since you're using jQuery, try the following.
$(document).ready(function() {
var myEl = $("#theBody");
myEl.on('click', function () {
launchIntoFullscreen(myEl[0]);
}).trigger("click");
});
Upvotes: 1
Reputation: 5964
This requires the user to click on myEl
:
myEl.addEventListener('click', function () {
launchIntoFullscreen(document.getElementById("theBody"));
}, false);
All you need is:
launchIntoFullscreen(document.getElementById("theBody"));
Upvotes: 1