How to detect the window close event.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • romepatel
    New Member
    • Nov 2009
    • 31

    How to detect the window close event.

    I have an parent-child window. I need to refresh the parent window when the child window is closed. I had tried
    Code:
    <body onunload="window.opener.location.reload();">
    When i navigate to different page in the child window , each and every time the parent window is refreshed. I want to refresh it only when the child window is closed. How can i do that?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    but when i navigate to different page in the child window , each and every time the parent window is refreshed...... ..
    the unload event just means "if you leave this page", this can be either closing the window or loading a new page, so the behaviour you see is correct (in terms of code).

    Comment

    • romepatel
      New Member
      • Nov 2009
      • 31

      #3
      Thanks for your reply.......

      what your saying is true........
      but i need to refresh the parent page only when the child page is closed........! !!

      How do i do that.......?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Check from the parent window that the child is closed using the 'closed' property.

        Comment

        Working...