1

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

2
  • 2
    iframes are dated there are much better solutions such as ajax Commented Sep 19, 2011 at 5:16
  • 1
    yes true but this moment i have no options Commented Sep 19, 2011 at 5:17

2 Answers 2

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>
Sign up to request clarification or add additional context in comments.

5 Comments

this is ok once redirect the iframe i want to refresh my parent window also without changing ifame contnet
The state of the iframe will not be retained once its parent window has been reloaded. Your only option at that point would be to default the source of the iframe once the parent window has been reloaded.
Another option might be to use DOM manipulation and get rid of the iframe altogether.
is there any way to refresh only parent object instead of ifame
No. However, if you take my suggestion regarding DOM manipulation you will eliminate the complexity and overhead associated with several round trips to the server, which ultimately creates a segmented and choppy experience for the end-user.
1

I do not seat by the computer 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

1 Comment

this is ok once redirect the iframe i want to refresh my parent window also without changing ifame contnet –

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.