When a user navigates away from a page, I want to have them confirm they are leaving the page:
window.onbeforeunload = function(){
if($('.fancy-blue-button.check-toggle').text() == 'Check In Task'){
return 'Note that this task will automatically be checked back in once you leave this page.';
}
};
$(window).unload(function() {
alert('Handler for .unload() called.');
});
The first one, onbeforeunload
works, the second one, unload
, does not seem to do anything.