faqts : Computers : Programming : Languages : JavaScript : Frames

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

44 of 68 people (65%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I Reload the parent window from within a function in the IFrame
I have a link in an iframe that I want to refresh the parent Page. Can anyone help me?

Feb 11th, 2003 08:19
John MacLaren, Narayan Janardan, brendan dugan,


This is how I approached it:

This Javascript function is inside the IFRAME source code.

<SCRIPT LANGUAGE="JavaScript">

function changeParentLocation(inLocationURL) {

    self.parent.location.href = inLocationURL;

}

</SCRIPT>

In other client side Javascript code I just pass in the URL of where I 
want the main parent window location to change to, usually another page 
within the site but it could be any URL.

What I also found was if I changed the location directly in the HREF 
tag of a link within the IFRAME the IFRAME text would change to show 
the URL text instead of keeping the same data showing.  By moving the 
location.href change to a function it eliminated that behaviour.