Substitute for ALLOW_KEYBOARD_INPUT javascript full screen

前端 未结 2 2093
庸人自扰
庸人自扰 2021-02-13 19:39

I have been searching on the internet for a reason why my fullscreen javascript doesn\'t work in Safari, but yet works in webkit browser Chrome. It seems to that safari doesn\'t

相关标签:
2条回答
  • 2021-02-13 19:54

    This has been fixed in Safari 10.1!

    Under the "Safari Browser Behavior" section.

    0 讨论(0)
  • 2021-02-13 20:10

    According to Apple's documentation, this is supposed to work in Safari 5.1 and later, but obviously it doesn't. I filed a bug report with Apple (which they don't make public), and the reply was as follows:

    Engineering has determined that this issue behaves as intended based on the following: We intentionally disable keyboard access in full screen for security reasons.

    I have replied asking that they at least update the documentation and make the lack of feature support detectable somehow. I will update here if I get a reply.

    Unfortunately, there isn't a good way to even do feature detection, since element.ALLOW_KEYBOARD_INPUT is defined in Safari, and the function call with that flag doesn't throw an error. The only remaining option is to parse the user agent string (try this library).

    Obviously, Apple doesn't yet document which version supports this, but according to this, it stopped working as of v5.1.2. That would leave a very small number of people using 5.1 un-patched, if it ever even worked at all. So it's probably not even worth detecting the version.

    As a fallback, I would expand the desired DOM element to fill the browser window by setting CSS height and width to 100% and position to "fixed" or "absolute".

    Update: It looks like the documentation has been corrected and no longer mentions the ALLOW_KEYBOARD_INPUT flag.

    0 讨论(0)
提交回复
热议问题