zoukankan      html  css  js  c++  java
  • js实现Html网页全屏效果

     1  //全屏
     2         function toggleFullScreen() {
     3             if (!document.fullscreenElement && // alternative standard method
     4                 !document.mozFullScreenElement && !document.webkitFullscreenElement) {// current working methods
     5                 if (document.documentElement.requestFullscreen) {
     6                     document.documentElement.requestFullscreen();
     7                 } else if (document.documentElement.mozRequestFullScreen) {
     8                     document.documentElement.mozRequestFullScreen();
     9                 } else if (document.documentElement.webkitRequestFullscreen) {
    10                     document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
    11                 }
    12             } else {
    13                 if (document.cancelFullScreen) {
    14                     document.cancelFullScreen();
    15                 } else if (document.mozCancelFullScreen) {
    16                     document.mozCancelFullScreen();
    17                 } else if (document.webkitCancelFullScreen) {
    18                     document.webkitCancelFullScreen();
    19                 }
    20             }
    21         }

    直接调用即可:

    <button onclick="toggleFullScreen()">全屏模式</button>

    原创文章,转载请说明出处,谢谢合作
  • 相关阅读:
    HDOJ 3547 DIY Cube 解题报告
    一些经典的期望问题

    人生
    BZOJ 4341 [CF253 Printer] 解题报告
    BZOJ 4302 Buildings 解题报告
    OI 回忆录
    PyQt实现测试工具
    PyQt:eg4
    pyQt: eg3
  • 原文地址:https://www.cnblogs.com/lwl80/p/14643423.html
Copyright © 2011-2022 走看看