View Full Version : javascript close child window check parent window

06-19-2007, 12:34 PM

I'm quite a javascript novice and need some help.
I've got a site with a portfolio section that opens as a new window at a specific size. I want to be able to close the portfolio (child) window, but I want to check that the parent window is still open before closing the child window. Can I do this?
And can I open the parent window if it is closed on closing the child? Basically I don't want someone to have closed the parent, then close the child window and end up with no windows open...
I've got bits of javascript in there, but to be honest I could do with a bit of clean code all round.
The site is at: http://www.zikotown.com/websitedev/homepage_d.htm
If you click on either the fox or racoon you will see the child page. At the minute when you close the portfolio child page (back to zikotown button) I've got it opening the main site again - but this is really rubbish!

I hope this makes sense to someone out there! Any assistance would be very gratefully received.

Thank you

06-19-2007, 04:56 PM
This is how you check the opener window from the child window.

if (opener && !opener.closed){
alert("Opener is open.");
else {
alert("Opener is closed.");