其他答案已经描述了如何以或多或少独立于浏览器的方式全屏显示。
但是,需要用户交互的问题仍然存在。
出于安全原因,您不能强制网页以全屏模式显示。
为此需要用户交互。
此外,每当用户转到另一个页面时,即使在同一个网站上,浏览器也会退出全屏模式,并且(s)他必须在每个页面上执行一些“用户交互”才能返回全屏模式。
这就是为什么您的网站必须是单页才能全屏显示的原因。
这就是我的建议:
使用具有隐藏 iFrame 的单个启动页面。
每当用户点击任意位置或按下任意键时,只需将此 iFrame 设置为全屏并显示即可。当您收到离开全屏模式的事件时,再次隐藏 iFrame 以显示启动画面。
默认情况下,链接在同一框架中打开,因此您将保持全屏模式,直到用户明确离开它或某些链接在新选项卡中打开。
这是一个适用于 Chrome 的示例:
(See it in action. 使用其他答案使其独立于浏览器。)
<html>
<head>
<script language="jscript">
function goFullscreen() {
// Must be called as a result of user interaction to work
mf = document.getElementById("main_frame");
mf.webkitRequestFullscreen();
mf.style.display="";
}
function fullscreenChanged() {
if (document.webkitFullscreenElement == null) {
mf = document.getElementById("main_frame");
mf.style.display="none";
}
}
document.onwebkitfullscreenchange = fullscreenChanged;
document.documentElement.onclick = goFullscreen;
document.onkeydown = goFullscreen;
</script>
</head>
<body style="margin:0">
<H1>Click anywhere or press any key to browse <u>Python documentation</u> in fullscreen.</H1>
<iframe id="main_frame" src="https://docs.python.org" style="width:100%;height:100%;border:none;display:none"></iframe>
</body>
</html>
但是请注意,网站通常不允许嵌入,例如在 iframe 中显示。该示例最初使用 W3Schools 网站而不是 Python 文档,但他们将“X-Frame-Options”标头设置为“sameorigin”(不允许跨站点嵌入)并且它停止工作。
附:我喜欢在浏览器中模拟完整操作系统的想法,而且全屏效果更好! :) Change your OS!
另外,我不是网络开发人员。只是觉得这个问题调查起来会很有趣。