JS 点击全屏

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>   <head>     <title>New Document</title>     <meta name="Generator" content="EditPlus">     <meta name="Author" content="">     <meta name="Keywords" content="">     <meta name="Description" content="">   </head>   <body>     <button id="view-fullscreen">Fullscreen</button>     <button id="cancel-fullscreen">Cancel fullscreen</button>     <script>       var viewFullScreen = document.getElementById("view-fullscreen");       if (viewFullScreen) {         viewFullScreen.addEventListener("click",         function() {           var docElm = document.documentElement;           if (docElm.requestFullscreen) {             docElm.requestFullscreen();           } else if (docElm.msRequestFullscreen) {             docElm.msRequestFullscreen();           } else if (docElm.mozRequestFullScreen) {             docElm.mozRequestFullScreen();           } else if (docElm.webkitRequestFullScreen) {             docElm.webkitRequestFullScreen();           }         },         false);       }       var cancelFullScreen = document.getElementById("cancel-fullscreen");       if (cancelFullScreen) {         cancelFullScreen.addEventListener("click",         function() {           if (document.exitFullscreen) {             document.exitFullscreen();           } else if (document.msExitFullscreen) {             document.msExitFullscreen();           } else if (document.mozCancelFullScreen) {             document.mozCancelFullScreen();           } else if (document.webkitCancelFullScreen) {             document.webkitCancelFullScreen();           }         },         false);       }     </script>   </body>

</html>

posted @ 2016-07-14 11:22  mrt_yy  阅读(693)  评论(0编辑  收藏  举报