Home > Back-end >  HTML 5 full screen and exit full screen display
HTML 5 full screen and exit full screen display

Time:01-26

[the entry and exit full screen]

//its (works in Safari5.1 and Chrome 15)
Element. WebkitRequestFullScreen ();
Document. WebkitCancelFullScreen ();

//Firefox 10 +
Element. MozRequestFullScreen ();
Document. MozCancelFullScreen ();

//the W3C proposed
Element. RequestFullscreen ();
Document. ExitFullscreen ();

[compatible solution]


1//to enter full screen
2 the function requestFullScreen () {
3 var DE=document. DocumentElement;
4 the if (DE requestFullscreen) {
5 DE. RequestFullscreen ();
{6} else if (DE mozRequestFullScreen)
7 DE. MozRequestFullScreen ();
{8} else if (DE webkitRequestFullScreen)
9 DE. WebkitRequestFullScreen ();
10}
11}
12//exit full screen
13 function exitFullscreen () {
14 var DE=document;
15 the if (DE exitFullscreen) {
16. DE exitFullscreen ();
17} else if (DE) mozCancelFullScreen) {
18 DE. MozCancelFullScreen ();
19} else if (DE) webkitCancelFullScreen) {
20 DE. WebkitCancelFullScreen ();
21}
22}

Note: probably because of security concerns, can only be achieved manually triggered a full-screen, the browser automatically performs no results,

[example]

Document. The body. The addEventListener (' click ', function () {
RequestFullScreen ();
//5 seconds automatically exit full screen
SetTimeout (function () {
ExitFullscreen ();
}, 5000);
},false);
  • Related