The project needs to be the Background browser window full screen, that is, we click on a button to achieve the effect of pressing F11 full screen. In the HTML5, the website has developed a full-screen API, you can achieve the full display effect, you can also make the page images, videos and other full screen currently only Google Chrome +, SAFRI5.1+,FIRFOX10+,IE11 support
Fullscreen?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
var docElm = document.documentElement; //W
3
C if (docElm.requestFullscreen) {
docElm.requestFullscreen(); } //FireFox else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen(); } //Chrome等 else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen(); } //IE
11 else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen(); }
|
Exit Full Screen?
1 2 3 4 5 6 7 8 9 10 11 12 |
if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } |
Event Monitoring?
1 2 3 4 5 6 7 8 9 10 |
document.addEventListener(
"fullscreenchange"
, function () {
fullscreenState.innerHTML = (document.fullscreen)?
"" :
"not "
;}, false);
document.addEventListener(
"mozfullscreenchange"
, function () {
fullscreenState.innerHTML = (document.mozFullScreen)?
"" :
"not "
;}, false);
document.addEventListener(
"webkitfullscreenchange"
, function () {
fullscreenState.innerHTML = (document.webkitIsFullScreen)?
"" :
"not "
;}, false); document.addEventListener(
"msfullscreenchange"
, function () {
fullscreenState.innerHTML = (document.msFullscreenElement)?
"" :
"not "
;}, false);
|
Full-screen style settings
In the browser full-screen use We can also make style settings
?
1 2 3 4 5 6 7 8 9 10 11 |
html:-moz-full-
screen {
background
:
red
; }
html:-webkit-full-
screen {
background
:
red
; } html:fullscreen {
background
:
red
; }
|
Appendix
11 Online Demos
http://robnyman.github.io/fullscreen/
2 HTML5 full Screen API phishing
http://www.36ria.com/5807
3 Full-screen plugin for jquery packages
http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
4 more detailed full-screen API introduction
4.1 Https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
4.2 https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html