2016-09-30 36 views
0

ログインから、新しいウィンドウで開くメインページに移動するようなレポートページを開きたいとします。メインページには、2つのボタンがあります。任意のボタンをクリックすると、そのボタンに関連付けられた特定のレポートが新しいウィンドウで開きます。親ウィンドウからすべての子ウィンドウを閉じる

問題は、各レポートページにリンクがあり、メインページに戻る必要があるということです(レポートページを最小限に抑える必要があります)。また、ユーザーが2番目のレポートを再度開くと、新しいウィンドウで開き、メインページへのリンクをクリックして2番目のレポートウィンドウも最小化する必要があります。

また、メインページ、第1レポート、第2レポートの3ページにログアウトがあります。メインページからログアウトをクリックすると、最小化されたすべてのウィンドウがあれば閉じることができます。他のページからログアウトをクリックすると、セッションを無効にする必要があります。

ので、流れは Flow

私の問題は、私がログアウトが最初から呼び出されたときに、第2子ウィンドウを閉じることはできませんよであるBE-でしょう。また、メインページからログアウトが呼び出された場合は、すべてのポップアップウィンドウを閉じます。私がログインからメインページを開くために使用しています

コード -

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

[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'と全く同じメソッドとプロパティを持っています。どちらも同じ "window"です。 –

+0

おかげで今私はそれをしています。 – shv22

関連する問題