用户要求在未保存离开时要给出提示,正好记得cnblogs上有这个功能,所以整理的一下。
<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="">
<INPUT TYPE="button" value="save" onclick="bypassCheck();saveClick()">
</FORM>
</BODY>
</HTML>
<script language="javascript">
var g_blnCheckUnload = true;
function RunOnBeforeUnload()
{
if(g_blnCheckUnload)
{
window.event.returnValue = '你将丢失没有保存的内容';
}
}
function bypassCheck()
{
g_blnCheckUnload = false;
}
onbeforeunload=RunOnBeforeUnload;
</script>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="">
<INPUT TYPE="button" value="save" onclick="bypassCheck();saveClick()">
</FORM>
</BODY>
</HTML>
<script language="javascript">
var g_blnCheckUnload = true;
function RunOnBeforeUnload()
{
if(g_blnCheckUnload)
{
window.event.returnValue = '你将丢失没有保存的内容';
}
}
function bypassCheck()
{
g_blnCheckUnload = false;
}
onbeforeunload=RunOnBeforeUnload;
</script>