title: How to get window object by name in Javascript?
body: <p>my query is, to close all child windows(if open) after logout. 
  I am creating child window from different jsps &amp; i want to close it from Search.jsp. 
  Search.jsp has buttons like Create, Logout.</p>
  
  <p>My Search.jsp is - </p>
  
  <pre><code>    &lt;%
  String sessionstart = (String)session.getAttribute("sessionstart");
  
  if(sessionstart != null)
  {
  %&gt;
  
  &lt;body&gt;
          &lt;div align="center" &gt;   &lt;img src="images/Headerimage.png" alt=""&gt; &lt;/img&gt;&lt;/div&gt;
  
  
          &lt;div id = "leftmargin" &gt;
          &lt;form action="Search" method="post"&gt;
              &lt;table cellspacing="10" cellpadding="10"&gt;
                  &lt;tr &gt;
                      &lt;td  &gt;Type&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="type" value="*" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&amp;nbsp;&amp;nbsp;Name&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="name" value="*" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&amp;nbsp;&amp;nbsp;Description&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="description" value="*" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="submit" value="Search" /&gt;&lt;/td&gt;
  
                  &lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;
  
                      &lt;td&gt;&lt;h5&gt;    &lt;input type="button" value="Create" onclick="Create();" /&gt;&lt;/h5&gt;    &lt;/td&gt;
     &lt;td&gt;  &lt;h5&gt;   &lt;input type="button" value="Logout" onclick="Logout(); " /&gt; &lt;/h5&gt;    &lt;/td&gt;
  
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  
      &lt;%
          if (sessionset != null) {
      %&gt;
      &lt;div align="center" style="margin-top: 15%"&gt;
          &lt;img src="images/DocumentManagementSplash.png" alt=""&gt; &lt;/img&gt;
      &lt;/div&gt;
      &lt;%
          }
      %&gt;
  &lt;/body&gt;
  
  &lt;% 
   }
  else
  {
  %&gt;
  &lt;script&gt;
  window.location.replace("ietmLoginDialog.jsp");
  &lt;/script&gt;
  &lt;%  
  }
  %&gt;
  
  &lt;script type="text/javascript"&gt;
      function Create() {
          window.open("ltIEnterCreatePartFileUpload.jsp?", "CreatePart",
                  "height=140,width=350");
      }
  
      function Logout() { 
  
      var w = document.getElementsByName("mywin");
      alert("w closed :: "+ w.closed);
      alert("w name :: "+ w.name);
      alert("w open:: "+ w.open); 
  
          if(w.name == "mywin"){
            w.close();
          }
  
          window.open("ietmLoginDialog.jsp", '_self', "location=yes");
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here , if i click on the logout button, then it must close all the OPEN child windows.
  The childs windows i am creating from different jsp's.
  For example, from Search.jsp, I open property page ie.,</p>
  
  <pre><code>&lt;td style="width: 170px;" &gt;&lt;a
                              href="ltSearchDocProperties.jsp?idvalue=&lt;%=strObjectId%&gt;"
                              onclick="window.open(this.href, 'mywin',
  'left=20,top=20,width=900,height=725'); return false;"&gt;&lt;%=strName%&gt;&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>From Property.jsp, i open edit jsp ie.,</p>
  
  <pre><code>&lt;h5 align="right"&gt; 
  &lt;a href="ltSearchDocEdit.jsp?idvalue=&lt;%=strObjectId%&gt;" onclick="window.open(this.href, 'mywiirn','width=900,height=615,resizable=false'); return false;"&gt;Edit&lt;/a&gt; &amp;nbsp;&amp;nbsp;&lt;/h5&gt;
  </code></pre>
  
  <p>&amp; likewise. 
  As of my knowledge, I can achieve this if i am creating the child window from same jsp ie. Search.jsp only.</p>
  
  <p>My readings are - </p>
  
  <p><a href="https://stackoverflow.com/questions/12175930/how-to-close-all-the-child-pages-on-logout">How to close all the child pages on LogOut</a></p>
  
  <p><a href="http://www.coderanch.com/t/460745/HTML-CSS-JavaScript/Close-multiple-child-windows-parent" rel="nofollow noreferrer">How to Close multiple child windows from a parent window</a></p>
  
  <p>Again this describes only if the window reference is in jsp only.
  So please suggest me, How i can close all child windows, creating from different jsp's
  from another jsp(Search.jsp) ?</p>
  
  <p>Any advice or any other way to achieve this, will be very much helpful for me.</p>
  
  <p>Thanks in advance.</p>