I want to have a confirm box when user tries to close the window.
window.onbeforeunload = function (evt) {
var mes
I assume that on page load, you are setting up var sncro=1; and when some data changes, you adjust this value. Here is the quick check:
window.onbeforeunload = function (evt) {
if (sncro != 1) {
var message = 'Are you sure you want to leave, cause there are some unsaved changes?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt ) {
evt.returnValue = message;
}
return message;
}
}