• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

child/parent window detection

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We would like to logout a user if they close their browser, and this can be done with onbeforeunload="logout()". However, if the user has opened multiple windows, we only want to call logout() when the last window is closed, and not if any window is closed.

How can a JS method detect if there are any other parent or children windows still running ?
window.top() does not seem to work in this case - is this only useful for frames ?

thanks,
-Jeff
 
Jeff Hubert
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that if( window.opener != null ) then this must be a child window. However there doesn't seem to be an easy way to detect if there are any other related windows still running, or if the parent is still running.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If JavaScript does not open the window, then you have no control of it.

Eric
reply
    Bookmark Topic Watch Topic
  • New Topic