hi,
i have aded window unload event handler to my code. my page calls some function that takes few secs and page then loads in 5-6 secs. while ths page is loading, if user clicks 'x' on browser window, then code inside unload event handler doesnt get executed. if user waits for page to be loaded fully and hten clicks 'x', then unload event handler gets executed. but i want if during loading user decides to click 'x' button, then also unload handler shold get exucted. i am pasting a sample code that simulates my situation:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function unloadPage() {
alert('unloaded page');
}
function pauseJS(timeInMilliS) {
var date = new Date();
var curDate = null;
do {
curDate = new Date();
}while(curDate-date < timeInMilliS);
}
</script>
</head>
<body onload="pauseJS(6000)" onunload="unloadPage()">
<p>Test Page</p>
</body>
</html>