Wordpress Themes - Debt Consolidation - Bollywood News - Find jobs - Kamala

PDA

View Full Version : Detecting window close


tamilsoft
May 9th 2008, 4:30 am
Hi,

I want to alert a message when the user trying to close the browser's window [like in gmail]. Can anyone help me?

GreatMetro
May 9th 2008, 8:44 am
<head>
<title>Detecting browser close in IE</title>


<script type="text/javascript">

var myclose = false;

function ConfirmClose()
{
if (event.clientY < 0)
{
event.returnValue = 'Any message you want';

setTimeout('myclose=false',100);
myclose=true;
}
}

function HandleOnClose()
{
if (myclose==true) alert("Window is closed");
}

</script>
</head>


<body onbeforeunload="ConfirmClose()" onunload="HandleOnClose()">