如何重定向Iframe到另一个URL php


How to redirect Iframe to another URL php

我有一个父页面index.php在它里面我有iframe像下面

<div id="main-content1" style="position:absolute;float:none;top:80px;margin-left:170px;width: 830px;">
            <iframe onload="IfarmeOnload();"  style="display:block; margin-left:none;  margin-right:none; width: 100%; height: 100%;" src="<?php echo $home; ?>" id="rightMenu" name="rightMenu"   frameborder="0"></iframe>
        </div>

当我点击位于父窗口的链接时,我想根据该URL重定向iframe内容。

然后一旦Iframe加载成功,我想重定向整个index.php页面只有一次

编辑

i tried this

echo "<script> document.getElementById('rightMenu').contentWindow.location='http://www.google.lk'</script>";

,但这是重定向到谷歌。在ifamme

内不加载

给你的iframe起个名字:

<iframe name="myIframeName"></iframe>

使用target属性在所需的超链接中引用iframe:

<a href="/path/to/page.php" target="myIframeName"></a>

我不坐在电脑旁边,但我认为你需要这样的东西. getelementbyid (rightMenu) .location.href

或者试试这个iframeobj。SRC = url

或者相同的代码,但没有contentwindow