onUnload, window.open, and browser buttons



Hello all,

I want to open a window when a user leaves my site. I set up a function called by onUnload. To skip the window.open if the user hasn't left my site, I set a variable in my links and test for it in the onUnload function. If the variable is set, don't open the window. If it's not -- if the user is leaving my site -- do open the window.

The problem is dealing with the browser Back, Forward, and Reload buttons. I don't want the window opening if the user hits one of them, but my flag variable isn't set. My workaround is to set up an onLoad function that tries to close the window if it's open. But it seems that to get that to work, I need a defined window handle, and to define the handle I arrived at attempting to reopen the window before closing it. But that, essentially, causes the browser to flash, even if the (re-)open is a 1x1 window positioned off-screen.

Is there a way to test if the window exists and is open? If there is, I can test for that condition before trying to close it.

Or is there a better solution for my need? Would it make a difference if I used the main browser window rather than a pop-up?

Thanks!

Seth, grimes at altaplana.com
.