在 Safari 5.1.2 中传递 Element.ALLOW_KEYBOARD_INPUT 时 webkitRequestFullScreen 失败
当尝试使用 javascript 全屏 api 时,特别是在 Safari 5.1.2 中遇到以下问题。
通过将以下行复制并粘贴到浏览器中加载的页面上,您可以看到效果。
这适用于 Chrome 15 和 Safari 5.1.2:
javascript:document.querySelector('body').webkitRequestFullScreen();
这适用于 Chrome 15,但在 Safari 5.1.2 中静默失败:
javascript:document.querySelector('body').webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
根据此处的文档,ALLOW_KEYBOARD_INPUT 似乎应该适用于 Safari:http://developer.apple.com/library/safari/#documentation/ WebKit/Reference/ElementClassRef/Element/Element.html
有什么想法为什么这不起作用吗?
Running into the following problem specifically in Safari 5.1.2 when attempting to use the javascript fullscreen api.
By copy and pasting the following lines into your browser on a loaded page, you can see the effect.
This works in Chrome 15 and Safari 5.1.2:
javascript:document.querySelector('body').webkitRequestFullScreen();
This works in Chrome 15 but fails silently in Safari 5.1.2:
javascript:document.querySelector('body').webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
ALLOW_KEYBOARD_INPUT seems like it should work in Safari, according to documentation here: http://developer.apple.com/library/safari/#documentation/WebKit/Reference/ElementClassRef/Element/Element.html
Any ideas why this isn't working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是已知的 Safari 错误。它可以在全屏切换期间嗅探:
使用这种实时嗅探,因此您的代码将支持将来修复 Safari 中的错误。
This is known Safari bug. It can be sniffed during full screen switching:
Use this real time sniffing and thus your code will support future fixing bug in Safari.
someElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)
适用于 Chrome。并且
someElement.webkitRequestFullScreen()
适用于 safari 5.1.7所有测试均基于 Windows 7。
someElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)
works in chrome.And
someElement.webkitRequestFullScreen()
works in safari 5.1.7All test base on windows 7.
我刚刚遇到了同样的问题,这绝对是一个错误。
这可能是不可检测的情况。我猜我们将不得不使用良好的浏览器嗅探。
[编辑] ...在这种情况下无法进行键盘输入。所以我想暂时最好在 Safari 中取消全屏模式 [/edit]
请记住,全屏 API 目前还处于非常早期的阶段,不应该在生产中使用
I just ran into the same issue, and this is most definitely a bug.
This may be a case of the Undetectables. Guess we're gonna have to use good ol' browser sniffing.
[edit] ...in which case keyboard input isn't possible. So I guess it's best to cut out fullscreen mode in Safari for the time being [/edit]
Keep in mind that the fullscreen API is in a very early stage at the moment, and should not be used in production