我从随机视频中有一个标准的YouTube嵌入iframe:
<iframe width="560" height="315"
src="https://www.youtube.com/embed/ixJ5NbvXg_A" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
我重复了几次,以获得一些滚动溢出。
<html>
<head></head>
<body>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</body></html>
当我在本地主机上使用django服务器提供此服务时,iframe会阻止页面滚动。
将光标移到视频上,然后使用鼠标滚轮滚动时,它将不起作用。
真正有趣的是,当我粘贴相同的代码并将其保存到桌面上的本地文件中时。然后使用chrome打开它,滚动条将在youtube视频上播放。
我检查了开发人员工具,所提供的文件具有完全相同的HTML。 没有100%没有提供CSS或Javascript,没有模板,什么也没有。 两种情况下只有一个简单的html文件。
版本71.0.3578.98(正式版本)(64位)
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以尝试像这样更改body的css
body{
overflow: auto;
}
答案 2 :(得分:0)
听起来像浏览器中的错误;这是一个简单的脚本,可以防止它发生。它将滚动事件添加到窗口,每当页面滚动时,该事件都会禁用iframe上的指针事件,然后在滚动停止后100毫秒重新启用它们。由于该事件是在捕获模式下添加的,因此会在iframe捕获该事件之前触发。
<script>
(function() {
var iframes, locked = null;
window.addEventListener("scroll", scroll, true);
function scroll(e) {
if (!locked) {
iframes = document.querySelectorAll('iframe');
lock('none');
}
clearTimeout(locked);
locked = setTimeout(function() {
locked = null;
lock('auto');
}, 100);
}
function lock(value) {
for (var i = 0; i < iframes.length; i++) {
iframes[i].style.pointerEvents = value;
}
}
})();
</script>
答案 3 :(得分:0)
这在我的浏览器中很好用:
<html>
<head></head>
<body>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/Mm2eYfj0SgA" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</body></html>
您可以发布一个片段重现该问题吗?
答案 4 :(得分:0)
我的特别问题是Chrome中的错误。如果重新启动浏览器,它将得到解决。