Click to See Complete Forum and Search --> : Closing a Popup Window after it Looses Focus
trbates
07-19-2003, 04:28 PM
Is there a way to automatically close a popup window once it looses focus?
For example ... I want to use a popup to show pictures from a site I am working on, however if the user does not close the child window after clicking back to the parent window I want the child to automatically close.
Thanks in Advance
Travis
David Harrison
07-19-2003, 04:47 PM
How's this:
<body onBlur="window.close();">
Edit: Or if you want to close the window only if they return to the parent window put this in the parent's source:
<body onFocus="pop-up_window_name.close();">
Charles
07-20-2003, 06:33 AM
Note, those handlers are onblur and onfocus. It doesn't matter in HTML because HTML is case insensitive but the will not work in XHTML or in JavaScript.
trbates
07-20-2003, 11:00 AM
That works perfectly, thank you all very much :)
Travis
David Harrison
07-20-2003, 04:08 PM
I think I picked up the capitals out of habit so that it's easier to see where one word ends and the next begins, like in:
document.getElementById
Guess I've got to un-learn that now then.
Charles
07-20-2003, 06:29 PM
It is a bit counter-intuitive. JavaScript follows the Java naming conventions and hence with that sort of identifier has each internal word starting with a capital (http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html). I guess the thinking is that the handlers are one word.