Reputation: 97
Im just a newbie here in javascript .. Can somebody help me?
I need to full screen my page after i click a certain button/link for example .. i'm on page1 and when i click the button it will redirect me to page2 and will be automatically on full screen ..
i have this code for fullscreen ..
<script type="text/javascript">
// Find the right method, call on correct element
function launchFullScreen(element) {
if(element.requestFullScreen) {
element.requestFullScreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}
</script>
<button onclick =" launchFullScreen(document.documentElement);">fullscreen!</button>
---this code fullscreen only the current page, what i need is to navigate first to another page then fullscreen.. thanks in advance .. all responses/opinion are appreciated ..
Upvotes: 2
Views: 6050
Reputation: 731
You should use instead of . In page 2 use this code:
<script>
function launchFullScreen(element) {
if(element.requestFullScreen) {
element.requestFullScreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
}
}
window.onload = function () {
launchFullScreen(document.documentElement);
}
</script>
UPD:
First of all sorry for misinformation. You can't fullscreen onload.
Instead of window.onload
you should use
<a href="page2" onclick="launchFullScreen(document.documentElement)"></a>
So while page is loading the browser will go into full screen mode.
Upvotes: 1
Reputation: 3600
You cannot Full Screen the Browser on page load.Full screen can be done only by user event.I was also having the same problem:
https://wiki.mozilla.org/Gecko:FullScreenAPI#Suggested_UA_Policy
Upvotes: 0