Mik*_*ike 13 javascript css browser firefox google-chrome
我使用以下 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>
Run Code Online (Sandbox Code Playgroud)
但在全屏模式下显示“按 esc 退出全屏”。如何在 Firefox 和 Chrome 中删除“按 esc 退出全屏”?
小智 60
在 Firefox 中这非常简单:
about:configbrowser.fullscreen.exit_on_escapetrue其更改为false| 归档时间: |
|
| 查看次数: |
9717 次 |
| 最近记录: |