title: In Google Chrome, how do I bring an existing popup window to the front using javascript from the parent window?
body: <p>I would like to have a button on a web page with the following behavior:</p>
  
  <ul>
  <li>On the first click, open a pop-up.</li>
  <li>On later clicks, if the pop-up is still open, just bring it to the front.  If not, re-open.</li>
  </ul>
  
  <p>The below code works in Firefox (Mac &amp; Windows), Safari (Mac &amp; Windows), and IE8.  (I have not yet tested IE6 or IE7.)  However, in Google Chrome (both Mac &amp; Windows) later clicks fail to bring the existing pop-up to the front as desired.  </p>
  
  <p>How can I make this work in Chrome?</p>
  
  <pre><code>&lt;head&gt;
    &lt;script type="text/javascript"&gt;
      var popupWindow = null;
      var doPopup = function () {
        if (popupWindow &amp;&amp; !popupWindow.closed) {
          popupWindow.focus();
        } else {
          popupWindow = window.open("http://google.com", "_blank",
            "width=200,height=200");
        }
      };
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;button onclick="doPopup(); return false"&gt;
      create a pop-up
    &lt;/button&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><em>Background: I am re-asking <a href="https://stackoverflow.com/questions/2530572/using-javascript-how-do-i-bring-an-already-existing-open-window-to-the-front-on">this question</a> specifically for Google Chrome, as I think I my code solves the problem at least for other modern browsers and IE8.  If there is a preferred etiquette for doing so, please let me know.</em></p>