Detect refresh button in the browser

Hi Marcus,

thanks for your reply over the mail, and here I am, reviving an old thread.

With regards to your method below, I am still confused (I have a similar need as the thread starter). To summarise again, my application will write to the database each time the user log in and log out (to prevent multiple login). So, when the user closes the browser / leave the page, I would like it to write to the database; but not when he refresh the page.

What I have done is that, I have specified the unload and load method (I am using .net) in the aspx file as follows:

<body MS_POSITIONING=“GridLayout” onload=“setTimeout(‘myFunc()’, 20000)” onbeforeunload=“setTimeout(‘myFunc()’, 10000)”>

And I have the java script function as (just an example)
<script language=“javascript”>
function myFunc()
{
window.open(‘http://www.microsoft.com’);
}
</script>

It seems that after I left the page, the function myFunc is not executed. However, if I stay at the page, it’s being executed.

Do help to correct the mistakes that I made above. (not sure if I have the right thing by using client side scripting)

Thank you very much.

Rgds,