Odd one this (aren't they always).

I have a popup window which absolutely must not be allowed to be placed in the background. Easy, I thought. Set the onblur property to window.close(). If I do this on a normal page, it works (either with window.onblur="window.close()" or by setting onblur-"window.close()" in the <body> tag).

The problem is, the popup is dynamically created. I've tried using

popupWin.document.write('<body onBlur=\"window.close();\">\n');



and neither works (although if I right-click and "view source" the first option correctly places the code in the tag).

I suspect I need the window to re-process it's contents once written, but how do I get it to do that? Or is there something else I could so?

The problem arises because if the user clicks the link that brings up the popup, backgrounds it, then clicks the link again, it all goes horribly wrong. An alternative would be if I could, using the code the ling fires off, detect if the window already exists and if so, bring it to the front, clear it out and then re-populate it.

Anyone got any ideas?

This is the last problem I need to solve before rolling out a major upgrade to our internal management system, so it's fairly urgent!

Thank you one and all!