javascript - YouTube iframe 嵌入违规 : non-passive event listener to a scroll-blocking 'touchstart' event

标签 javascript iframe youtube warnings passive-event-listeners

我在我的网站上嵌入了一个 youtube iframe,它在我的控制台中抛出了以下警告:

[违规] 向阻止滚动的“touchstart”事件添加了非被动事件监听器。考虑将事件处理程序标记为“被动”以使页面更具响应性。见 https://www.chromestatus.com/feature/5745543795965952 base.js:4560

[违规] 'setTimeout' 处理程序耗时 115 毫秒 www-embed-player.js:583

我确定它是这个组件,因为当我将其注释掉时,警告就会停止。我想摆脱这些警告。这个怎么做?

<iframe width="100%" height="300px" src="https://www.youtube.com/embed/wHcyxs6pGIk" frameborder="0" allow="accelerometer; autoplay; gyroscope; picture-in-picture" allowfullscreen></iframe>

最佳答案

我一直有同样的错误。这是我看到的唯一一篇解决这个问题的帖子。在链接中,警告会指示您查看:Github EventListenerOptions/explainer.md
在文件中,它说:

There are a few more complicated scenarios where the handler only wants to suppress scrolling under certain conditions, such as: ... A UI element (like YouTube's volume slider) which slides on horizontal wheel events without changing the scrolling behavior on vertical wheel events. Since there is no equivalent of "touch-action" for wheel events, this case can only be implemented with non-passive wheel listeners.


由于 YouTube 的音量 slider ,这个错误似乎是不可避免的。

关于javascript - YouTube iframe 嵌入违规 : non-passive event listener to a scroll-blocking 'touchstart' event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56780548/

相关文章:

javascript - 如何修复 iframe 中嵌入式 YouTube 视频的无限加载?

youtube - 如何将所有YouTube channel 视频嵌入网站..?

youtube - Google Cloud Video智能和嵌入式视频内容

javascript - 日期时间选择器布局错误

asp.net-mvc-4 - IE11 IFrame 内容无法加载

javascript - 添加后选择一行

http - Golang 反向代理以避免 SOP

python - YouTube数据API注释问题

javascript - 查找对象中最接近的整数

javascript - 根据值返回字母等级