我将该下面代码加入了我自己的页面中,这样当我直接关闭IE窗口时也出现提示框,但是问题是我的页面上有不少打开新窗口的JavaScript语句,当点击它们时也出现了提示框,这是为什么?
<body onbeforeunload="RunOnBeforeUnload()" id="Posts">
<script language="javascript">
g_blnCheckUnload = true;
function RunOnBeforeUnload()
{if (g_blnCheckUnload) {window.event.returnValue = 'You will lose any unsaved content';
}
}
function bypassCheck()
{ g_blnCheckUnload = false;
TempSave(document.getElementById('Editor_Edit_txbTitle'),Editor_Edit_ftbBody_ClientID.GetDocument().body.innerHTML
);
}
</script>
g_blnCheckUnload = true;
function RunOnBeforeUnload()
{if (g_blnCheckUnload) {window.event.returnValue = 'You will lose any unsaved content';
}
}
function bypassCheck()
{ g_blnCheckUnload = false;
TempSave(document.getElementById('Editor_Edit_txbTitle'),Editor_Edit_ftbBody_ClientID.GetDocument().body.innerHTML
);
}
</script>