I know that this was probably discussed earlier, but I wonder how Facebook really successfully implements this function - at https://www.facebook.com/messages/new : When composing a message, and then when trying to click the "Back" button "in the browser, I get my own custom facebook dialog, which checks that I really want to leave the page.
I know that I can use the beforeunload event to open my own dialog, but how to create my own custom one, for example Facebook.
I realized that one way probably uses jQuery and fires an event in the whole set of links.
But how does it work for everything else (for example, the back button in the browser).
I figured this might have something to do with the PushState control or the fact that facebook probably uses some infrastructure on the client side, and when I click "Back" I DO NOT actually UNLOAD the window.
In any case, we will be happy to receive information about this problem.
source share