在 Safari 5.1.2 中传递 Element.ALLOW_KEYBOARD_INPUT 时 webkitRequestFullScreen 失败

发布于 2024-12-20 07:09:57 字数 717 浏览 2 评论 0原文

当尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三五鸿雁 2024-12-27 07:09:57

这是已知的 Safari 错误。它可以在全屏切换期间嗅探:

someElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
if (!document.webkitCurrentFullScreenElement) {
    // Element.ALLOW_KEYBOARD_INPUT does not work, document is not in full screen mode
}

使用这种实时嗅探,因此您的代码将支持将来修复 Safari 中的错误。

This is known Safari bug. It can be sniffed during full screen switching:

someElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
if (!document.webkitCurrentFullScreenElement) {
    // Element.ALLOW_KEYBOARD_INPUT does not work, document is not in full screen mode
}

Use this real time sniffing and thus your code will support future fixing bug in Safari.

梦醒灬来后我 2024-12-27 07:09:57

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.7

All test base on windows 7.

所有深爱都是秘密 2024-12-27 07:09:57

我刚刚遇到了同样的问题,这绝对是一个错误。

这可能是不可检测的情况。我猜我们将不得不使用良好的浏览器嗅探。

...(/Safari/.test(navigator.userAgent) ? undefined : Element.ALLOW_KEYBOARD_INPUT)

[编辑] ...在这种情况下无法进行键盘输入。所以我想暂时最好在 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.

...(/Safari/.test(navigator.userAgent) ? undefined : Element.ALLOW_KEYBOARD_INPUT)

[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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文