想做个功能就是关闭页面时先判断用户有没有盖章,如果盖章了直接就把数据传给后台,如果没有盖章就让用户确认是否确认关闭
//关闭IE时检查盖章操作是否完成
var winClose = true;
function window.onbeforeunload()
{
getValue();
//关闭IE时不弹出提示按钮
window.opener = null;
winClose = event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey;
//关闭
if(winClose)
{
//无效凭证不发送后台
var retCode = document.getElementById("retCode").value;
if(retCode > 0){
return;
}
//盖章结束
if(newEsealID == stampLength)
{
var theForm = document.forms[0];
//theForm.action ="./backSealServlet";
theForm.action ="./SendServlet";
theForm.submit();
//盖章没有结束
}else{
document.getElementById("retCode").value = "5000"; //返回码5000表示/用户只是显示但并不做盖章操作
return "盖章操作未完成,您确定退出么?";
}
}
//刷新
//else
// {
// alert("刷新");
// }
}
function window.onunload()
{
winClose = event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey;
//关闭
if(winClose)
{
var theForm = document.forms[0];
//theForm.action ="./backSealServlet";
theForm.action ="./SendServlet";
theForm.submit();
}
}
本文介绍了一种在用户关闭浏览器窗口前进行数据同步的方法。通过判断用户是否已完成盖章操作来决定是否将数据发送到后台。若已完成,则自动提交;若未完成,则提示用户确认是否关闭。
308

被折叠的 条评论
为什么被折叠?



