繁体   English   中英

防止 iframe js 自动滚动父页面

[英]Prevent iframe js from auto scrolling the parent page

我们有一个页面,上面有一个视频,嵌入了一个 iframe。

播放器的 iframe js 代码中包含以下代码:

m.default.focus(function (e) {
          var t = e.playButton;
          (0, y.focusElement) (t)
        })

这基本上使播放按钮在屏幕上可见(如果还没有)。 这适用于独立视频,但不适用于我们嵌入视频的页面。

它在我们页面上的框架是导致整个页面滚动到该内容。

如果可能的话,我们想防止这种情况发生。

这是 iframe 代码:

<div class="embed-responsive mb-5 embed-responsive-16by9" id="myFrame" style="height: auto;">
    <iframe allowfullscreen="" class="embed-responsive-item" sandbox="allow-scripts allow-downloads-without-user-activation allow-same-origin" src="https://sourcefile.onthesamedomain.com" title="Video"></iframe>
</div>

我们已经尝试在父级上滚动到 0,0,但这没有用。

抱歉,但我忘了补充一点,这只是 Firefox 中的一个问题。 其他浏览器使用 iframe 上的属性。

任何帮助,将不胜感激。

iframe 中 js 的第 3 方所有者最终提供了修复。 如果屏幕不来回滚动,我们就无法做到这一点。

暂无
暂无

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

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