Possible Duplicate:
Capturing result of window.onbeforeunload confirmation dialog
I want to make user confirm page navigation like that:
window.onbeforeunload = function(e) {
return "Note that any unsaved data will be lost";
};
however, I want to detect if user clicked "Stay in this page" to do something important. So is there anyway to detect which button is clicked?
NB: I tried adding confirm in the onbeforeunload
function but chrome block it.