Is there a way to perform a jQuery animation before a user navigates away from a page by clicking on a link, or clicking the back/forward buttons.
It seems like doing the animation in response to an unload event would be sure to cover all the conditions under which a user may leave a page.
However, the new page is loaded before the animation can complete. I could do a busy wait, but that isn't very elegant.
Alternatively, I could intercept clicks on anchors. But that doesn't account for back/forward clicks and possibly other conditions under which user would navigate away from a page.
Yes, I understand that this type of behavior is frowned upon because it leaves the user waiting. However, I am attempting to do this in a very particular situation in which I believe the pros outweigh the cons.