onBeforeUnload
The instruction(s) to be executed are placed within quotes. This event handler will execute the instruction(s) when the page is about to be unloaded from a window or a frame.

The following example will display text of your choosing in a message box when the page is about to be unloaded from a window or a frame:
onBeforeUnload="msgWindow.document.write('-- Insert text message here --')"
This Event Handler is used with the following:

BODY
FRAMESET
TD
TEXTAREA
TH