Friday, 27 September 2013

JavaScript - Run code when user confirms leaving page

JavaScript - Run code when user confirms leaving page

I want the user to confirm that he wants to leave the page. I do that this
way with jQuery:
$(window).bind('beforeunload', function(){
return "Are you sure?";
});
If the user says "yes", I want to run a function before the browser tab
closes. Is this possible? And how, in that case?

No comments:

Post a Comment