Here are suggested solutions that look reasonable
http://www.ilovebonnie.net/2009/09/23/how-to-use-onbeforeunload-with-form-submit-buttons/
UPDATE (link dead) - copied content from Google Cache
How to use onbeforeunload using form submit buttons
September 23, 2009 - Geekery
. , , , , ( ) onbeforeunload.
, AJAX/JavaScript, , (, IE , , - JavaScript). , , , , .
:
window.onbeforeunload = function () {
return "You are about to leave this order form. You will lose any information...";
}
, , , , , , . , , , :
var submitFormOkay = false;
window.onbeforeunload = function () {
if (!submitFormOkay) {
return "You are about to leave this order form. You will lose any information...";
}
}
onclick, , onsubmit submit, , submitFormOkay true , :
<input type="submit" id="submit_button" onclick="submitFormOkay = true;">