从childs iframe访问父iframe

时间:2009-08-25 14:25:47

标签: iframe parent-child parent

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

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

当我点击iframe1中的链接时,我需要在iframe2中显示生成的页面。我试过了:

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

但这不起作用。

任何人都知道如何做到这一点?

2 个答案:

答案 0 :(得分:3)

我认为你可能需要JavaScript。像

这样的东西
 onclick="javascript:parent.i2.document.location='blah.html'"

答案 1 :(得分:2)

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

您只需要将“i2”放在此页面中,它应该是唯一的窗口名称。无需指定父等。