title: Check if a popup is opened or not
body: <p><br>
  I need to open a popup on page load and than on each new page load I need to check if the popup is still there or not. When the is loaded a cookie is stored so, if the user closes the popup it will never opens again unless the user click to open it.<br>
  On page load I open the popup if the cookie is not set:</p>
  
  <pre><code>var page_id = getURLParameter('pageID'),
      popup_opened = readCookie('music_popup'),
      musicPopup;
  
  
  if(page_id !== 'music_popup' &amp; !popup_opened){
      musicPopup = window.open('?pageID=music_popup', 'musicPopup', 'height=720,width=980');
  };
  </code></pre>
  
  <p>What I need is a control on click event.<br>
  1- If user click on a link and the popup is still there, then focus on the popup.<br>
  2- if the popup is closed, than open it with focus.<br>
  I tried this code:</p>
  
  <pre><code>$('.c_music').click(function (event) {
      event.preventDefault();
      if (musicPopup !== undefined) {
          musicPopup.focus();
      } else {
          musicPopup = window.open('?pageID=music_popup', 'musicPopup', 'height=720,width=980');
      };
  });
  </code></pre>
  
  <p>This doesn't work because if I'm in a page that hasn't opened the popup "musicPopup" is always undefined and the popup is opened even if it is just open...
  I found this question: <a href="https://stackoverflow.com/questions/10468136/js-open-popup-window-and-acces-its-element-in-another-page">js open popup window and acces it&#39;s element in another page</a> where this code is suggested:<br>
  from page 1</p>
  
  <pre><code>var popup = window.open("test.html","mypopup","width=500,height=300");
  popup.document.getElementById("player").someFunction();
  </code></pre>
  
  <p>from page 2</p>
  
  <pre><code>var popup = window.open('','mypopup');
  // now popup is know again
  popup.document.getElementById("player").someFunction(); 
  </code></pre>
  
  <p>this works fine if the popup is still opened when page 2 load, but if the popup is closed than page 2 open a black popup...</p>
  
  <p>I'm going crazy... Any help would be really appreciate! </p>