【问题标题】:Is it possible to check for the id of the parent iframe? [duplicate]是否可以检查父 iframe 的 id? [复制]
【发布时间】:2013-11-20 21:34:51
【问题描述】:

假设我在 iframe 中有一个页面。

所以...

top page {
iframed page{
}
}

现在,我想给 iframe 页面一个 id。

在 iframe 页面的代码中,我可以检查 iframe 页面的 id 值是否等于某个值?

if ($('#iframeid', window.parent.document))

似乎不起作用。

【问题讨论】:

  • 只有在同一个域中才能这样做。
  • iframe 中的内容无法影响其封闭页面。如果可以的话,这将是一个非常糟糕的安全问题。
  • 他们在同一个域中。
  • 你所拥有的是正确的(对于同一个域)stackoverflow.com/questions/726816/…

标签: javascript jquery iframe


【解决方案1】:

如果是 Chrome 或 Firefox,你应该可以这样做:

 window.frameElement.id

在 iframe 中获取 iframe 本身的 id。

【讨论】:

猜你喜欢
  • 2014-09-30
  • 2011-06-03
  • 1970-01-01
  • 2013-04-21
  • 2011-05-21
  • 1970-01-01
  • 2012-08-06
  • 1970-01-01
  • 2018-10-30
相关资源
最近更新 更多