Click here to Skip to main content
15,917,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I aim to create a new Website, I need to make a button of fullscreen, when user click it all pages showed as full screen

What I have tried:

I search it and there is my trying:

<input type="button" value="click to toggle fullscreen" >
<input type="button" value="goto" >

and this is function

function toggleFullScreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}

}

function func() {
window.location.replace("second.aspx");
}

this works fine to show page in full screen but the problem is when it redirect to the second page it didn't support full screen on load

here is the code of second page

document.addEventListener("DOMContentLoaded", function (event) {
toggleFullScreen();
});

my question now is there any other way to make the all site support full screen mode from index page ?
Posted
Updated 12-Jul-16 1:11am
Comments
Philippe Mori 12-Jul-16 9:08am    
Use code block for your code. Unformatted code is hard to read.

1 solution

Read system environment using suitable library.
and on button click set screen size as your web sites page size.
this will make your website look like mode: fit to screen.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900