【问题标题】:Iframe current src with a redirection from a different domain to same domain具有从不同域重定向到相同域的 iframe 当前 src
【发布时间】:2013-04-18 03:56:10
【问题描述】:

我有一个来自 a.com 的页面,其中包含来自 b.com 的 iframe,经过一些操作后,b.com 最终将 iframe 重定向回 a.com。那么页面可以访问iframe的当前位置/src吗?

问候,

吉什努

【问题讨论】:

    标签: javascript iframe cross-domain


    【解决方案1】:

    一旦 iframe 中的页面在 a.com 上,安全限制就会解除,您可以像往常一样访问父页面。当 iframe src 更改时,安全限制也会更新,即使是 iframe 本身。

    如果您需要知道 iframe 何时最终定向回 a.com,您可以让它使用 window.parent.redirected() 调用父文档中的函数,其中 redirected() 是您在父文档中定义的函数.com。

    【讨论】:

      猜你喜欢
      • 2012-04-21
      • 2017-10-20
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-24
      • 2018-04-13
      • 2015-05-07
      相关资源
      最近更新 更多