美文网首页
js点击按钮模拟F11全屏

js点击按钮模拟F11全屏

作者: 甘道夫老矣 | 来源:发表于2024-03-11 10:31 被阅读0次
      // 点击全屏
        handleFullScreen(): void {
            if (this.isFullScreen) {
                // 取消全屏
                let el: any = document;
                if (el.exitFullscreen) {
                    document.exitFullscreen()
                } else if (el.webkitCancelFullScreen) {
                    el.webkitCancelFullScreen()
                } else if (el.mozCancelFullScreen) {
                    el.mozCancelFullScreen()
                } else if (el.msExitFulldcreen) {
                    el.msExitFulldcreen()
                }
                this.isFullScreen = false
            } else {
                // 全屏
                let element: any = document.documentElement
                if (element.requestFullscreen) {
                    element.requestFullscreen()
                } else if (element.webkitRequestFullScreen) {
                    element.webkitRequestFullScreen()
                } else if (element.mozRequestFullScreen) {
                    element.mozRequestFullScreen()
                } else if (element.msRequestFulldcreen) {
                    element.msRequestFulldcreen()
                }
                this.isFullScreen = true
            }
        }
    
    

    相关文章

      网友评论

          本文标题:js点击按钮模拟F11全屏

          本文链接:https://www.haomeiwen.com/subject/xejmzdtx.html