如何在iframe打开的弹出窗口中设置父级的位置。

时间:2011-09-24 06:23:39

标签: javascript iframe popupwindow

我想从iframe打开的弹出窗口设置父窗口的位置。

我在javascript中编写这行代码,但它无效。

window.opener.parent.location = '../Account/';

3 个答案:

答案 0 :(得分:5)

window.opener.parent.location.href = '../account/';

答案 1 :(得分:0)

尝试这样的事情

<b>iframe starts here</b><br><br>
<iframe src='iframe1.html'></iframe>

<br><br>
<b>iframe ends here</b>

<script type="text/javascript">
    function change_parent_url(url)
    {
    document.location=url;
    }       
</script>

在iframe中

<a href="javascript:parent.change_parent_url('http://yahoo.com');">
Click here to change parent URL </a>

因此,您可以看到子iframe调用父级的功能并提供网址

答案 2 :(得分:0)

应该使用

window.parent.location.href = '../account/';