zoukankan      html  css  js  c++  java
  • JS调用命令实现F11全屏

    <body onload ='autoSetFull()'>
      <button id='btn'>全屏按钮</button>  
      <div id="content" style="background:yellow;500px;height:500px;">sljfsdlfj  
          <div id="quite" class="btn">退出全屏</div>  
      </div> 
    <body> 
    <script type="text/javascript">
      function fullScreen(el) {  
          var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,  
              wscript;  
          if(typeof rfs != "undefined" && rfs) {  
              rfs.call(el);  
              return;  
          }  
          if(typeof window.ActiveXObject != "undefined") {  
              wscript = new ActiveXObject("WScript.Shell");  
              if(wscript) {  
                  wscript.SendKeys("{F11}");  
              }  
          }  
      }  
      function exitFullScreen(el) {  
          var el= document,  
              cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,  
              wscript;  
         
          if (typeof cfs != "undefined" && cfs) {  
            cfs.call(el);  
            return;  
          }  
         
          if (typeof window.ActiveXObject != "undefined") {  
              wscript = new ActiveXObject("WScript.Shell");  
              if (wscript != null) {  
                  wscript.SendKeys("{F11}");  
              }  
        }  
      }  
      var btn = document.getElementById('btn');  
      var content = document.getElementById('content');  
      btn.onclick = function(){  
          fullScreen(content);  
      }  
      var quite = document.getElementById('quite');  
      quite.onclick = function(){  
          exitFullScreen();  
      }  
    </script>
    

    PS:这种方法只能通过用户来触发,尝试页面加载后自动执行会提示错误。

  • 相关阅读:
    Find the Smallest K Elements in an Array
    Count of Smaller Number
    Number of Inversion Couple
    Delete False Elements
    Sort Array
    Tree Diameter
    Segment Tree Implementation
    Java Programming Mock Tests
    zz Morris Traversal方法遍历二叉树(非递归,不用栈,O(1)空间)
    Algorithm about SubArrays & SubStrings
  • 原文地址:https://www.cnblogs.com/wangxuehao/p/6845883.html
Copyright © 2011-2022 走看看