Tuesday, February 13, 2007

Javascript window_onbeforeunload Event

<script language=javascript for=window event=onbeforeunload>
return window_onbeforeunload()
</script>
<script>
function window_onbeforeunload()
{
var a = alert('You are about to close this window!');
if(a)
{
window.open(window.location,"_blank");
}
else
{
window.open(window.location,"_blank");
}
}
</script>

In this way you can process any Javascript code just before the browser will get closed.