我目前正在开发一个不会向公众发布的私有(private) Web 应用程序。它相对简单,可以在 Google Chrome 上运行。
当 DOM 准备好时,有没有人有强制浏览器进入全屏模式
的解决方案?我想简单地模拟 F11 键的 keypress
,但我不知道这是否可能。
除了将窗口大小调整为可用宽度并隐藏导航(不是理想的解决方案)之外,是否有人有 jQuery 解决方案。
最佳答案
正如其他人所说,由于已经提到的明显原因,这是不可能的。
尽管它是一个本地站点,但您为什么不全屏为其创建一个 Chrome 快捷方式:
创建 Chrome 的快捷方式:
"C:\Users\techiecorner\AppData\Local\Google\Chrome\Application\chrome.exe" --kiosk http://www.example.com
http://www.techiecorner.com/1941/how-to-auto-start-chrome-in-full-screen-mode-f11-everytime/
更新
现在 (HTML5) 有一个全屏 API 的提案。要使用它,您可以执行以下操作:
// feature detection
if (typeof document.cancelFullScreen != 'undefined' && document.fullScreenEnabled === true) {
// mozilla proposal
element.requestFullScreen();
document.cancelFullScreen();
// Webkit (works in Safari and Chrome Canary)
element.webkitRequestFullScreen();
document.webkitCancelFullScreen();
// Firefox (works in nightly)
element.mozRequestFullScreen();
document.mozCancelFullScreen();
// W3C Proposal
element.requestFullscreen();
document.exitFullscreen();
}
有关详细信息,请参阅 official specs .
关于javascript - 在 Chrome 中强制全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8126996/