【问题标题】:Trigger close event of child iframe from within iframe, but without storing/passing iframe element ID?从 iframe 中触发子 iframe 的关闭事件,但不存储/传递 iframe 元素 ID?
【发布时间】:2020-06-11 09:26:51
【问题描述】:

thisthis 之类的问题类似,但没有一个是相同的。

假设窗口 A 和子 iframe B,都在同一个域中。

如何从子 iframe 本身访问 iframe 元素?

最终目标是在不传递/存储有关 iframe 的 ID/名称信息的情况下关闭子 iframe (B)。理想情况下,有一个从子 iframe 到父窗口的回调,并且这个回调函数包含对子 iframe 的引用。然后父级在此引用上调用remove

无需传递/存储与子 iframe 相关的 ID 信息。

这可能吗?

【问题讨论】:

    标签: javascript html iframe


    【解决方案1】:

    window.frameElement 让您可以访问iframe 元素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多