如何在Firefox和Chrome中删除按esc退出全屏?

时间:2015-01-16 17:53:29

标签: javascript css google-chrome firefox browser

我使用此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退出全屏”。 如何在firefox和chrome中删除“按esc退出全屏”?

1 个答案:

答案 0 :(得分:0)

你做不到。这是一个安全功能,旨在不让恶意网站误导或陷入用户 - 这不是你可以删除的东西。