Possible Duplicate:
javascript detect browser close tab/close browser
I am doing a real time game site in php, I wish to call a function on closing the browser, how can i detect closing the browser using php or javascript ? I have tried using onbeforeunload and onunload events, but found that these events are triggered even if the window is refreshed or navigates using back button, forward button etc.. And also these events are not working well in all popular browsers. Is there any posible way to detect only the window close event which performs well in all browsers?
Thanks in advance