我使用以下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退出全屏”?
2条答案
按热度按时间qij5mzcb1#
在Firefox中非常简单:
1.在URL栏中输入
about:config
1.同意安全风险
1.搜索条目
browser.fullscreen.exit_on_escape
1.双击
true
将其更改为false
1.你完成了!享受:-)
sauutmhj2#
这是一项安全功能,旨在防止恶意网站误导或诱捕用户,您无法删除它。