ユーザーがページから離れたときに、ページを離れることを確認してもらいたい:
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.');
});
最初のものはonbeforeunload
動作しますが、2 番目のものunload
は何もしないようです。