I want to call a servlet when a window is closed.I used onunload(),but that is triggered even at the times when i refresh the page or click a link on the page. But, i want that my function should be triggered only when i close the window. Can anyone tell me how can i do that.
Actually, we have some files on server side that needs to be deleted when the client closes the browser.When client is refreshing the window or if he is clicking the link, it means he still wants to view the window.So, in that case we can not delete the files.We have to delete the files, only when we are sure user is done with viewing our window and now he is closing the window.
Please tell me the solution if the situation is clear to you.
Besides, the onunload (and onbeforeunload) events aren't specified in W3 HTML specification. Although the major webbrowsers supports them, you shouldn't rely that the webbrowser used by the client supports it. For example Opera, which usually follows the W3 specs extremely strictly, doesn't support it.