View Full Version : Detecting Browser Window Closings

07-25-2002, 06:13 PM
I've seen sights that do popup windows whenever you close their pages and I was wondering where I can get something like that or how ever they do it.


Maximus - DFX
07-25-2002, 06:55 PM
To my knowledge you can only do this in IE. All you have to do it put:

window.onbeforeunload=function(){return ''}

The return '' means that no text of your own will appear in the pop-up box. You can put text between the quotes if you want some of your own text to appear. Basically this handler allows people and stay on the page incase they made a mistake and didn't mean to exit the page.

07-25-2002, 07:21 PM
I think that what you mean is how you can load other urls when you close a window.

It is quite easy if you use the onUnload event, this event make happen when you unload or close the window. In this moment you can open a new window, show a message,...

<body onUnload="alert("This can be a solution");">

I think that is what you want. :thumbsup:

07-25-2002, 07:47 PM
SWEEEEEET, they're both what I what I was looking for.

Thanks tons,