A frabjous cheater method is to always have a warning window placed
under your current working window. If the user exits the page In Accordance With Prophecy, the under-window is closed first, then the outer window. If they are so misguided as to bail out before you want them to, then upon dismissing the top window, they see the warning.
Furthermore, if you keep in that warning window a series of invisible controls dictating the current state of the app, one of the buttons "Bring it all back -- I'm misguided to want to leave now!" will completely restore their previous state. Voila!
That, at least, is how I would do it.
The trouble with popping up windows using the onunload event is that most browsers are
well-behaved and won't do that kinda' junk upon exiting. Exiting is supposed to kill all child procs as well as the current one and a sudden pop-up window is quite definitely a child proc. IE is sloppy, however, and urges its children to strike out on their own, regardless of their broken home. Exploiting this allows unscrupulous marketers to populate your screen with all sorts of pop-up windows if you're running IE.
So, a possible solution for you, plus an explanation of one of the trickier bits.
Cheers,
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
Edward
"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door