Click to See Complete Forum and Search --> : Closing a pop-up on loss of focus


Geat
03-28-2003, 07:09 AM
I've got a little javascript information window that pops up on the click of a button, and I want it to close when it loses the focus.

<body onBlur="window.close()"> thinks that clicking on anything inside the window counts as the window losing focus, and as my window has form controls within it, this is no good!

Is there a way of closing the window only when it is sent to the back...

Cheers.

Phil Karras
03-28-2003, 02:26 PM
OK, interesting, have you tried putting that in a function that can first check to see if focus is still on an element inside you page?

So, ever time you click on something inside you page it sets a var which is first checked then by the function containing the close() method, if the var is OK then reset the var and continue.

I don't know if this will work because onBlur() is a pain in the $#! at times, but I have done similar things and gotten them to work, though with a great deal of effort!