我想在用户尝试关闭窗口时有确认框。关闭标签前确认框
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;
}
的事情是我想检查一个变量看重
var sncro=1;
如果其值不等于1个,则该确认框应there..else没有必要有一个确认。我无法想象这个..它很愚蠢,但我要求任何人都可以看看代码。
通过“导航走”,而不是关闭相关:http://stackoverflow.com/questions/925734/whats-this-in-javascript-onclick都与'解决onbeforeunload' 。 – 2014-07-10 21:44:32