> Yes, the JavaScript code can run before the browser is closed but it would
> not be finish running because the browser closing had been executed.
> Someone had tried it before and struggled with it.   But that is a good
> advice, thanks for jumping in.
I really doubt that browsers doesn't run the code that is in unload event of
the page because the window is closed. That would be a very bad thing. Isn't
it what the unload event is for? I mean to run code when the page is
unloaded, it doesn't matter if the window is being closed or the user is
going to another page. I think the browser should finish all the opened
window's unload code and only after that close the application really.
I made a quick test for it:
<html>
<head>
<script language=javascript>
function wait(msec){
 var enter_date = new Date();
 var enter_time = enter_date.getTime();

 var leave_date = new Date();
 var leave_time = leave_date.getTime();

 while (enter_time + msec > leave_time)
 {
  leave_date = new Date();
  leave_time = leave_date.getTime();
 }
 alert('unload test');
}
</script>
</head>

<body onunload="wait(5000)">
 unload test
</body>
</html

It works fine for me in ie6 and mozila 0.9.6, it shows the alert message
after about 5 seconds.

    Arpi




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to