最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to redirect Iframe to another URL php - Stack Overflow

programmeradmin3浏览0评论

I have parent page index.php and inside it i have iframe like below

<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>

when i click on the link that located in Parent window i want to redirect iframe content to according to that URL.

Then once Iframe loaded sucessfully i want redirect whole index.php page only once

EDIT

i tried this

echo "<script> document.getElementById('rightMenu').contentWindow.location=''</script>";

but this is redirecting to google.lk to not loading inside the ifamme

I have parent page index.php and inside it i have iframe like below

<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>

when i click on the link that located in Parent window i want to redirect iframe content to according to that URL.

Then once Iframe loaded sucessfully i want redirect whole index.php page only once

EDIT

i tried this

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

but this is redirecting to google.lk to not loading inside the ifamme

Share Improve this question edited Sep 19, 2011 at 5:14 Roshan Wijesena asked Sep 19, 2011 at 4:54 Roshan WijesenaRoshan Wijesena 3,1369 gold badges40 silver badges58 bronze badges 2
  • 2 iframes are dated there are much better solutions such as ajax – user557846 Commented Sep 19, 2011 at 5:16
  • 1 yes true but this moment i have no options – Roshan Wijesena Commented Sep 19, 2011 at 5:17
Add a ment  | 

2 Answers 2

Reset to default 6

Give your iframe a name:

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

Reference your iframe in desired hyperlinks with the target attribute:

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

I do not seat by the puter but I think You need something like that Document.getElementById("rightMenu").location.href

Or try this one iframeobj.src = url

Or the same code that you wrote but without contentwindow

发布评论

评论列表(0)

  1. 暂无评论