Window.onBeforeClose event


Event executed right before closing and destroying the window.

Accepts a true/false return value, which allows/denies window closing.

newWindow.onBeforeClose=function(win_id){
    return confirm('Close?');
};