I am trying to achieve two goals on my website:
1. A button that switches to full screen mode.
2. When passing between pages the full screen mode will remain.
I was able to achieve the two goals seperately but not together.
The situation right now is:
1. the button switches to full screen mode using this code:
<script>
function toggleFullScreen() {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}
</script>
<li class="quicklinks"> <a href="#" class="layout-condensed-fullwidth" id="layout-condensed-width" >
<div onclick="toggleFullScreen();" class="iconset top-menu-fullpage-dark"></div>
</a> </li>
But, when switching pages the full screen mode quits!
When switching to full screen mode via clicking on F11 (and not as described above) I was able to make the full screen persistent with this code:
<script> function fullscreen(){ $('a').click(function() { if(!$(this).hasClass('noeffect')) { window.location = $(this).attr('href'); return false; } }); $(document).ready(function() { fullscreen(); }); </script>
But I could not find a way to combine those two. The code in section 2 has effect only if you press F11. Any ideas on why it happens and what can help solve this issue?
Thanks!