弹出窗口没有从父窗口关闭?

时间:2016-10-20 13:39:40

标签: javascript html

我在关闭弹出窗口时遇到问题。我的问题是独一无二的,如果我从父母点击Logout,它会关闭所有窗口,但是当我从一个孩子退出时,我将从Parent注销,因此它不会关闭其他打开的子窗口。

当我从一个孩子退出然后我从父母退出时,我检查了控制台,它没有进入if块。

我打开所有这样的弹出窗口 -

function openpop1() {
    sessionId = getURLParameters('requestID');
    userName = getURLParameters('userName');
    userId = getURLParameters('userId');
    lvalue = getURLParameters('lValue');
    lver = getURLParameters('lVer');
    window.name = "parent";
    var intWidth = screen.width - 10; //Adjust for the end of screen 
    var intHeight = screen.height - 80; //Adjust for the Icon Bar at the bottom of the window.
    var strWinProp = " toolbar=no"         //Back, Forward, etc...
                   + ",location=no"      //URL field
                   + ",directories=no"   //"What's New", etc...
                   + ",status=yes"       //Status Bar at bottom of window.
                   + ",menubar=no"       //Menubar at top of window.
                   + ",resizable=yes"     //Allow resizing by dragging.
                   + ",scrollbars=yes"   //Displays scrollbars is document is larger than window.
                   + ",titlebar=yes"     //Enable/Disable titlebar resize capability.
                   + ",width="+intWidth    //Standard 640,800/788, 800/788
                   + ",height="+intHeight  //Standard 480,600/541, 600/566               
                   + ",top=0"              //Offset of windows top edge from screen.
                   + ",left=0"             //Offset of windows left edge from screen.
                   + "";  
     awin = window.open(aUrl + userName + "&requestID=" + sessionId
            + "&userId=" + userId + "&lValue=" + lvalue + "&lVer=" + lver,'_blank',strWinProp);
}
function openpop2() {
    sessionId = getURLParameters('requestID');
    userName = getURLParameters('userName');
    userId = getURLParameters('userId');
    lvalue = getURLParameters('lValue');
    lver = getURLParameters('lVer');
    window.name = "parent";
    var intWidth = screen.width - 10; //Adjust for the end of screen 
    var intHeight = screen.height - 80; //Adjust for the Icon Bar at the bottom of the window.
    var strWinProp = " toolbar=no"         //Back, Forward, etc...
                   + ",location=no"      //URL field
                   + ",directories=no"   //"What's New", etc...
                   + ",status=yes"       //Status Bar at bottom of window.
                   + ",menubar=no"       //Menubar at top of window.
                   + ",resizable=yes"     //Allow resizing by dragging.
                   + ",scrollbars=yes"   //Displays scrollbars is document is larger than window.
                   + ",titlebar=yes"     //Enable/Disable titlebar resize capability.
                   + ",width="+intWidth    //Standard 640,800/788, 800/788
                   + ",height="+intHeight  //Standard 480,600/541, 600/566               
                   + ",top=0"              //Offset of windows top edge from screen.
                   + ",left=0"             //Offset of windows left edge from screen.
                   + "";  
     bwin = window.open(bUrl + userName + "&requestID=" + sessionId + "&userId="
            + userId + "&lValue=" + lvalue + "&lVer=" + lver,'_blank',strWinProp);
}

登出时我正在打电话

function onLogout() {
    if (awin && !awin.closed) {
        awin.close();
    }
    if (bwin && !bwin.closed) {
        bwin.close();
    }       

    sessionId = getURLParameters('requestID');
    var rcvReq = getXmlHttpRequestObject();
    rcvReq.onreadystatechange = function() {
        if (rcvReq.readyState == 4 || rcvReq.readyState == 0) {
            var data = rcvReq.status;
        }
    }
    rcvReq.open("GET", logoutUrl +sessionId, true);
    rcvReq.send(null);
    window.location = loginPageUrl;
}

现在我的问题是为什么当我从孩子然后从父母退出时它不会进入if块。我通过在这些行中添加断点来检查这一点。

 if (awin && !awin.closed) {
        awin.close();
    }
    if (bwin && !bwin.closed) {
        bwin.close();
    }    

我还检查了每当我关闭一个弹出窗口时,awin和bwin的值都设置为undefined。

但为什么会这样呢。有人可以帮我这个吗?

编辑: 这是因为如果我要退出,我在主页面上设置一个模态窗口供用户告诉会话超时。

这里的代码就在这里 -

if (responseBodyFull == "Invalid Session Id passed") {
                            console.log("Invalid Session");
                            showModalBoxForInvalidSessionInfo();
                           }

并且函数定义如下 -

function showModalBoxForInvalidSessionInfo(){
    $("#modelView").dialog({
        autoOpen : false,
        modal : true,
        buttons : [ {
            text : "OK",
            icons : {
                primary : "ui-icon-heart"
            },
            click : function() {
                $(this).dialog("close");
            }
        }]
    });
    $("#modelView" ).dialog("open");
    $("#modelView").text("Session Timed Out. Please login again to access the Dashboard");
}   

但无论如何,当我们执行console.log时,它会转到if部分。所以,我想这应该不是问题。

0 个答案:

没有答案