views:

38

answers:

1

Hi,

Is it possible to figure out just wich type of event triggered $(window).unload();? To be a bit more specific, I'm only interested in the event when a user has closed the window (a popup), not when he's just navigating away from the current page.

I've looked into the event parameter passed to the callback of unload(); but there doesn't seem to be anything in that object, that'll be of use.

Does anybody know a solution to this?

Code:

$(function() {
    $(window).unload(function(event) {
        // This is obviously pseudo code. Help me fix it!
        if(event.type == 'closing') { // I had expected something along these lines to work
            // Do stuff before the window closes
        }
    });
});
A: 

No, to my knowledge this is not possible. The document only learns that it is about to be unloaded. Why, is the browser's business.

Pekka
It seems that you are correct. Will just have to try a different approach then ;)
peterfarsinsen