Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript close child window check parent window

    Hi

    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
    Helen

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    This is how you check the opener window from the child window.

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •