I have a textarea in form. I want to show confirmation box when user close the window without save the content.
I have a code
var myEvent = window.attachEvent || window.addEventListener;
var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload'; /// make IE7, IE8 compitable
myEvent(chkevent, function(e) { // For >=IE7, Chrome, Firefox
var confirmationMessage = ' '; // a space
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
it works well. But i am getting the same confirmation box when i submit save button. How can i find whether submit button clicked or not?.
Thanks