Forum Moderators: open

Message Too Old, No Replies

Child window closing and refreshing parent window

How the heck do you do it?

         

giggle

11:04 am on Apr 10, 2004 (gmt 0)

10+ Year Member



I've searched WebmasterWorld and the web and I can't suss out how to refresh a parent window when the child window is closed.

I've found a couple of references but they're way to complicated for my JavaScript experience...

Anyone got any simple code sample that demonstrates how to do this? I've wasted a couple of days trying to sort it out myself and need the direction from some of you experts out there.

Thanks in anticipation.

Mick

Rambo Tribble

1:14 pm on Apr 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might try placing this in the body tag of the document in the child window:
onunload="parent.document.location.reload();"

I'm just not 100% sure a child has permission to act on its parent this way. I sure know I wouldn't want any kid of mine doing this to me.

ajkimoto

2:07 pm on Apr 10, 2004 (gmt 0)

10+ Year Member



giggle,

I assume by child window you mean a window that was opened by code in the opener window, and the opener window is the parent window.

If so, you can use the following code in the child window:

window.opener.location.reload();window.close()

window.opener is a reference to the window that opened the current window.

ajkimoto

giggle

3:09 pm on Apr 10, 2004 (gmt 0)

10+ Year Member



Thanks Rambo and Ajkimoto.

I'll try those out.

Ajkimoto - where would I put your line of code? Does it go in the OnUnload statement the same as Rambo suggested?

Cheers

Mick

ajkimoto

3:59 pm on Apr 10, 2004 (gmt 0)

10+ Year Member



Yes, attach it to the onunload event.

ajkimoto

giggle

4:26 am on Apr 11, 2004 (gmt 0)

10+ Year Member



Again, thanks Rambo and Ajkimoto.

I've tried the code and it works. I can move on now...

Cheers

Mick