Js enables full screen and exit of browser windows. Mainstream browsers on the market, such as Google, Firefox, and 360, are compatible, however, the earlier version of IE is a bit defective (the status bar at the bottom still exists in full screen mode ).
This demo is basically enough. Copy the following source code and save it as an html file to see the effect.
<! DOCTYPE html>
<Html>
<Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/>
<Title> JavaScript full screen and exit full screen code </title>
<Body>
<! -- RequestFullScreen(document.doc umentElement): The entire webpage enters full screen.
RequestFullScreen (document. getElementById ("video-box"): specifies the full screen of a certain area.
-->
<Button onclick = "requestFullScreen(document.doc umentElement)"> full screen display </button>
<Button onclick = "exitFull ()"> exit full screen </button>
</Body>
<Script type = "text/javascript">
Function requestFullScreen (element ){
// Judge various browsers and find the correct method
Var requestMethod = element. requestFullScreen | // W3C
Element. webkitRequestFullScreen | // Chrome, etc.
Element. Inclurequestfullscreen | // FireFox
Element. msRequestFullScreen; // IE11
If (requestMethod ){
RequestMethod. call (element );
}
Else if (typeof window. ActiveXObject! = "Undefined") {// for Internet Explorer
Var wscript = new ActiveXObject ("WScript. Shell ");
If (wscript! = Null ){
Wscript. SendKeys ("{F11 }");
}
}
}
// Exit full screen to determine the browser type
Function exitFull (){
// Judge various browsers and find the correct method
Var exitMethod = document. exitFullscreen | // W3C
Document. Optional cancelfullscreen | // Chrome, etc.
Document. webkitExitFullscreen | // FireFox
Document. webkitExitFullscreen; // IE11
If (exitMethod ){
ExitMethod. call (document );
}
Else if (typeof window. ActiveXObject! = "Undefined") {// for Internet Explorer
Var wscript = new ActiveXObject ("WScript. Shell ");
If (wscript! = Null ){
Wscript. SendKeys ("{F11 }");
}
}
}
</Script>
</Html>