简体   繁体   English

从父窗口关闭所有子窗口

[英]Close all the child window from Parent window

I want to open a Report Page such that from Login it should go to a Main Page which will itself open in a new window. 我想打开一个报告页面,这样从登录名应该转到一个主页,该主页本身会在新窗口中打开。 On Main Page, there are two buttons. 在主页上,有两个按钮。 Clicking on any button it will open a particular report associated with that button in new window. 单击任何按钮,它将在新窗口中打开与该按钮关联的特定报告。

Now, the problem is there is a link on each Report Page which should go back to Main Page (ie It should minimise the report page). 现在,问题在于每个“报告页面”上都有一个链接,该链接应返回到“主页”(即应将报告页面最小化)。 Also, if a user opens a second report again it will open in new window and hit the link to Main Page it should also minimise second report window. 同样,如果用户再次打开第二个报告,它将在新窗口中打开并单击指向“主页”的链接,这也应最小化第二个报告窗口。

Also, there is a logout on the 3 pages ie On Main Page, First Report and Second Report. 另外,在3页上也有注销信息,即在首页,第一份报告和第二份报告上。 So clicking on Logout from Main Page should close the all minimised window if there any. 因此,单击“从主页注销”将关闭所有最小化的窗口(如果有)。 On clicking Logout from any other page ie other reports it should invalidate the session. 在从任何其他页面(即其他报告)上单击注销时,它将使该会话无效。

So the flow would be- 因此,流程将是- 流

My problem is I am not able to close second child window when Logout is called from first. 我的问题是,从第一个调用注销时,我无法关闭第二个子窗口。 Also, if logout is called from Main page how to close all pop-up window. 另外,如果从主页调用注销,则如何关闭所有弹出窗口。

Code that I am using to open Main Page from Login - 我用来从登录名打开主页的代码-

function RedirectPage(path)
    {


      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.

                   + "";  

        var win = window.open(path,'_blank',strWinProp);
        self.setTimeout("closeMe()",500);
    }

Code to open Report from Main Page - 从主页打开报告的代码-

function report1() {
    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.

                   + "";  
    window.open(Url + userName + "&requestID=" + sessionId + "&userId="
            + userId + "&lValue=" + lvalue + "&lVer=" + lver,'_blank',strWinProp);
}

Same code I am using to open Report 2 just I am using different URL. 我使用不同的URL来打开报表2的代码相同。

On clicking logout from child I am calling this function - 在单击从孩子注销时,我正在调用此功能-

function logout()
    {


        opener.location.href = '/Login.html';
        close();
    }

Same logout function is used second child 第二个孩子使用相同的注销功能

Logout function for main page - 主页注销功能-

function onLogout(){

window.opener.location.reload(true);
window.opener.location.href=loginPageUrl;
window.close(); 
}

When open a window with: 当打开一个窗口时:

var win = window.open(path,'_blank',strWinProp);

that window can access his opener with: 该窗口可以通过以下方式访问他的开启器:

window.opener

Then, in each child window you can control his behaviour with is own window object, and call parent methods or properties with window.opener . 然后,在每个子窗口中,您可以使用自己的window对象控制其行为,并使用window.opener调用父方法或属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM