【问题标题】:Detecting element out of Iframe从 iframe 中检测元素
【发布时间】:2021-09-01 10:25:38
【问题描述】:

我正在检测我的内容是否在 iframe 之外。我一直在尝试一个直截了当的案例,但仍然无法检测到,基本上我正在填充 iframe,以便 iFrame 内的文档超出它的正文。

不知何故,我需要我的文档说“嘿,我在 iframe 的视口之外”。

已尝试使用文档的 clientHeight、BoundingClientRect()、visibilityState,但似乎没有任何效果。添加示例:

<html>
<head></head>
<body>
<b>iframe-4 includes the ad-iframe</b>
<iframe style="overflow:hidden; height:400px; width:400px; padding-left:700px; padding-top:750px" src="simpleHtmlDocWithoutAnyFancyStuff.html" scrolling="no">
</body>
</html>

【问题讨论】:

    标签: javascript html iframe intersection-observer getboundingclientrect


    【解决方案1】:

    您正在寻找的是Intersection API

    【讨论】:

      猜你喜欢
      • 2013-04-27
      • 1970-01-01
      • 2010-11-08
      • 2021-05-24
      • 1970-01-01
      • 1970-01-01
      • 2017-12-23
      相关资源
      最近更新 更多