如何将iframe重定向到另一个URL php

Ros*_*ena 1 javascript php iframe jquery

我有父页面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>
Run Code Online (Sandbox Code Playgroud)

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

一旦Iframe成功加载,我只需要重定向整个index.php页面一次

编辑

我试过这个

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

但这是重定向到google.lk而不是在ifamme中加载

Tim*_*ake 6

给你iframe一个名字:

<iframe name="myIframeName"></iframe>
Run Code Online (Sandbox Code Playgroud)

iframe使用以下target属性引用您所需的超链接:

<a href="/path/to/page.php" target="myIframeName"></a>
Run Code Online (Sandbox Code Playgroud)