想做个功能就是关闭页面时先判断用户有没有盖章,如果盖章了直接就把数据传给后台,如果没有盖章就让用户确认是否确认关闭
//关闭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();
}
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/13654.html