2016-09-30 174 views
0

我想打開一個報表頁面,以便從登錄時它應該進入主頁面,該頁面本身將在新窗口中打開。在主頁上,有兩個按鈕。點擊任何按鈕,它將在新窗口中打開與該按鈕相關的特定報告。關閉父窗口中的所有子窗口

現在,問題是每個報告頁面上都有一個鏈接應該返回到主頁面(即它應該最小化報告頁面)。另外,如果用戶再次打開第二個報告,它將在新窗口中打開並點擊鏈接到主頁面,它也應該最小化第二個報告窗口。

此外,還有3個頁面的註銷,即主頁,第一個報告和第二個報告。所以點擊從主頁面註銷應該關閉所有最小化窗口,如果有的話。點擊從其他任何頁面註銷,即其他報告,它應該使會話無效。

所以流將是─ Flow

我的問題是我不能夠關閉第二子窗口時註銷從第一調用。另外,如果從主頁面調用註銷,如何關閉所有彈出窗口。

代碼,我使用從登錄打開主頁 -

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); 
    } 

代碼從主頁打開報表 - 我使用打開報告2只是我

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); 
} 

相同的代碼我正在使用不同的URL。

在點擊註銷從孩子我調用這個函數 -

function logout() 
    { 


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

相同註銷功能用於第二個孩子的主頁

註銷功能 -

function onLogout(){ 

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

請make一個[mcve] – mplungjan

回答

0

當打開窗口:

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

該窗口可以訪問他的揭幕戰:

window.opener 

然後,在每個子窗口,你可以控制自己的行爲與自己的是對象window,並調用父方法或屬性與window.opener

+0

所以在孩子中我必須編寫window.opener然後父路徑? – shv22

+0

認爲子窗口中的'window.opener'是父窗口中'window'的引用。子窗口中的「window.opener」與父窗口的「window」具有完全相同的方法和屬性,兩者都是相同的「窗口」。 –

+0

好的。謝謝,我現在正在那樣做。 – shv22