gpt4 book ai didi

javascript - 在 iFrame 中引用时,“deviceorientation”不会在 iOS 浏览器中触发

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:31:44 25 4
gpt4 key购买 nike

我正在制作一个在 iframe 中运行“360 度全景查看器”的网站,其中源页面使用 JavaScript 和 window.DeviceOrientationEvent 来确定用户是否使用具有方向功能的移动设备。我在 iOS Safari 和 Chrome 上看到一些奇怪的行为:

window.DeviceOrientationEvent evaluates to true, but deviceorientation event is never triggered.

Android Chrome 不是这种情况 - 当在 iFrame 中使用时,事件会按预期连续触发。

直接访问页面(在 iOS 上)时,我看到事件触发。就好像在 iframe 中使用它以某种方式“阻止”了这个事件。

这对我来说意义不大,研究它揭示的信息很少,除了一些模糊的迹象 [1, 2] 它实际上可能与 CORS 有关 - 无论 iframe 源是否与 iframe 源位于同一根域父页面。这对我来说更没有意义..

有人知道吗?

1 2

最佳答案

对于现在遇到这个问题的任何人来说,Apple 似乎从 iOS 12.2 开始就禁用了 deviceorientation API。用户现在需要在 Settings > Safari > Motion and Orientation access 中明确切换它。参见 here供讨论。

关于javascript - 在 iFrame 中引用时,“deviceorientation”不会在 iOS 浏览器中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37262953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com