Forum Moderators: open
You cannot directly capture the window Close event. You can only capture onUnload and set a variable "flag" on every link to be sure that the onUnload isn't triggered because of a link being followed.
Here's a reference that offers some sample code:
[developer.irt.org...]
IE has (yet another) non-standard but nontheless useful event called onBeforeUnload. Using the event.returnValue property you can present the visitor with a warning if they try to navigate away from your page. eg:
<script>
function handleUnload()
{
event.returnValue = "Click cancel to return to the blah";
}
</script><body onbeforeUnload="handleUnload()">
If the user clicks Cancel then their navigation action is cancelled and the page doesn't unload.
You don't have much control over the dialog that appears (for obvious security reasons) but this event can be very useful in application territory to catch unsaved changes and the like. I've also noted that a few of the on-line banks are using this event in a frameset to warn people that they should logout etc.
Josh