0

在我的应用程序中,当用户注销时,浏览器已关闭。在浏览器关闭时,我会发出警报。现在我想要的是,如果我直接关闭浏览器窗口警报应该会出现,但是如果通过注销警报关闭窗口则不应该出现,因为我已经显示了另一个注销确认消息。

function closeEditorWarning(){
    for (var i=0;i<childWindow.length;i++) {
        if (childWindow[i] && !childWindow[i].closed) childWindow[i].close();
        if(i==0) {
            alert("This will close all open e-App applications");
        }
    }
    window.close();  
}
window.onbeforeunload = closeEditorWarning;

这是我的注销代码

    $('#'+id).click(function(event){
        event.preventDefault();
        $('#centerContent').load('<%=request.getContextPath()%>/'+target);
    });
} else {
    $('#'+id).click(function(event){
        event.preventDefault();
        var r=confirm("logout");
        if (r==true)
        {
            flag=true;
            for (var i=0;i<childWindow.length;i++) {
                if (childWindow[i] && !childWindow[i].closed) childWindow[i].close();
            }
            window.close();
        } else { }
    });
}
4

2 回答 2

0

设置具有用户登录状态并关闭检查的隐藏字段:

if($('#isUserLogIn').text()=='true')
{
  //show alert
}
于 2012-11-23T05:02:57.790 回答
0

使用旗帜。单击注销时设置标志。

在显示警报之前检查标志

于 2012-11-23T04:58:44.223 回答