Confirm box before closing a tab
Posted
by piemesons
on Stack Overflow
See other posts from Stack Overflow
or by piemesons
Published on 2010-03-16T08:39:33Z
Indexed on
2010/03/16
8:46 UTC
Read the original article
Hit count: 456
webbrowser-control
|JavaScript
I want to have a confirm box when user tries to close the window.
window.onbeforeunload = function (evt) {
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;
}
The thing is i want to check a variables value
var sncro=1;
If its value is not equal to one then this confirmation box should be there..else no need to have a confirmation. I m not able to figure this..Its soo silly but i request anybody can have a look on the code. thnks.
© Stack Overflow or respective owner