This is my scenario: A user start editing a post, upload a photo, but then he closes the browser, or jump to a different page.
I want to be able to delete the photo uploaded and warn the user of the consequnces.
I know there is a function window.onbeforeunload But I'm not sure if I get it right
window.onbeforeunload = askExit;
function askExit(){
return "Are you sure you want to exit this page?";
}
Now, how do I capture the button press "leave this page" So I can fire a second function to clean the session, photos, etc?