Username:

Password:

Remember me

 



Changing parent window's URL from IFRAME content

If you want to control parent window's URL from a child iframe, you can't use variable destination how you would use that for frames because tag <iframe> doesn't have this property.

Also you can't change parent.document.location variable because this variable is read-only for child iframes.

To solve this problem, you need to define a javascript function at parent window and call it from iframe window. Here's an example how to change parent window's URL:


Parent window's content:

    <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's content:

    IFRAME content<br><br>

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

So you can see that child iframe calls parent's function and gives URL to go to.









Rambler's Top100