【问题标题】:Accessing parent iframe from a childs iframe从子 iframe 访问父 iframe
【发布时间】:2009-08-25 14:25:46
【问题描述】:

好的,我有一个 html 页面,上面有两个 iframe。

-------------------------------------------------
|              PARENT                           |
|                                               |
|                                               |
|     [iframe1 id=i1 name=i1]                   |    
|                                               |
|                                               |
|                                               |
|     [iframe2 id=i2 name=i2]                   |
|                                               |
|                                               |
-------------------------------------------------

当我单击 iframe1 中的链接时,我需要在 iframe2 中显示结果页面。我试过了:

<a href=blah.html target=parent.i2>link</a>

但这不起作用。

有人知道怎么做吗?

【问题讨论】:

    标签: iframe parent-child parent


    【解决方案1】:

    我认为您可能需要 JavaScript。类似的东西

     onclick="javascript:parent.i2.document.location='blah.html'"
    

    【讨论】:

      【解决方案2】:
      <a href=blah.html target="i2">link</a>
      

      您只需要输入“i2”它应该是该页面中唯一的窗口名称。无需指定父母等。

      【讨论】:

      • 这个答案比我的好很多。
      • 谢谢,但你的回答也很好,只是方式不同而已。
      猜你喜欢
      • 2011-07-08
      • 2011-03-26
      • 2010-10-16
      • 2014-03-08
      • 2020-01-11
      • 1970-01-01
      • 2010-10-30
      • 2013-05-07
      • 1970-01-01
      相关资源
      最近更新 更多