简体   繁体   English

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

[英]webkitRequestFullScreen fails when passing Element.ALLOW_KEYBOARD_INPUT in Safari 5.1.2

Running into the following problem specifically in Safari 5.1.2 when attempting to use the javascript fullscreen api. 尝试使用javascript全屏api时,在Safari 5.1.2中特别遇到以下问题。

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: 这适用于Chrome 15和Safari 5.1.2:

 javascript:document.querySelector('body').webkitRequestFullScreen();

This works in Chrome 15 but fails silently in Safari 5.1.2: 这适用于Chrome 15,但在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 根据这里的文档,ALLOW_KEYBOARD_INPUT似乎应该可以在Safari中使用: http//developer.apple.com/library/safari/#documentation/WebKit/Reference/ElementClassRef/Element/Element.html

Any ideas why this isn't working? 任何想法为什么这不起作用?

This is known Safari bug. 这是已知的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. 使用这个实时嗅探,因此您的代码将支持Safari中的未来修复错误。

someElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT) works in chrome. someElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)在chrome中工作。

And someElement.webkitRequestFullScreen() works in safari 5.1.7 someElement.webkitRequestFullScreen()在safari 5.1.7中有效

All test base on windows 7. 所有测试基于Windows 7。

I just ran into the same issue, and this is most definitely a bug. 我刚遇到同样的问题,这绝对是一个错误。

This may be a case of the Undetectables . 这可能是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] 所以我想最好暂时在Safari中删除全屏模式[/ edit]

Keep in mind that the fullscreen API is in a very early stage at the moment, and should not be used in production 请记住,全屏API目前处于非常早期阶段,不应在生产中使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM