如何删除按esc退出全屏在火狐和 chrome ?

nbnkbykc  于 2022-12-06  发布在  Go
关注(0)|答案(2)|浏览(390)

我使用以下JavaScript代码全屏显示页面:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <div style="border:1px solid red;height:100px;width:100px;background-color:red;" onclick="requestFullScreen(document.body)"></div>
    <div style="border:1px solid red;height:100px;width:100px;background-color:blue;" onclick="exitFullScreen(document.body)"></div>

    <script>
        function requestFullScreen(element) {
            // Supports most browsers and their versions.
            var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;

            if (requestMethod) { // Native full screen.
                requestMethod.call(element);
            } else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
                var wscript = new ActiveXObject("WScript.Shell");
                if (wscript !== null) {
                    wscript.SendKeys("{F11}");
                }
            }
        }

    </script>

    <script>
        function exitFullScreen() {
            if (document.exitFullscreen) {
                document.exitFullscreen();
            }
            else if (document.msExitFullscreen) {
                document.msExitFullscreen();
            }
            else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
            }
            else if (document.webkitCancelFullScreen) {
                document.webkitCancelFullScreen();
            }
        }

    </script>
</body>
</html>

但在全屏模式下显示“按esc退出全屏”。如何在火狐和Chrome中删除“按esc退出全屏”?

qij5mzcb

qij5mzcb1#

在Firefox中非常简单:

1.在URL栏中输入about:config
1.同意安全风险
1.搜索条目browser.fullscreen.exit_on_escape
1.双击true将其更改为false
1.你完成了!享受:-)

sauutmhj

sauutmhj2#

这是一项安全功能,旨在防止恶意网站误导或诱捕用户,您无法删除它。

相关问题