title: How do I prevent Google Chrome from blocking my popup?
body: <p>On my website there is a button that just used to call a function that calls <code>window.open</code>, however, recently an adjustment was needed to do a server-side check before the popup was opened.</p>
  
  <p>Ever since the code was added that does the AJAX call, browsers blocks the popup, that is opened in the <code>success</code> callback of the AJAX call. I read that browsers might block the popup if it's not called by a user click event, so I tried setting the AJAX request to <code>async: false</code>, which solved the problem in Firefox, but Google Chrome still keeps blocking my popup. Is there any way to get around this?</p>
  
  <p>I could move the server-side check to the page that gets opened in the popup, but I'd like to do it before opening the popup, if possible.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;a id="attackButton" href="#"&gt;Attack Base!&lt;/a&gt;
  
  &lt;script type="text/javascript"&gt;
  $(function() {
      $('#attackButton').click(function() {
          $.ajax({
              url: baseurl + '/index.php?option=com_pbbgs&amp;format=raw&amp;getinfo=goingame',
              data: { 'gameid': 618 },
              dataType: 'text',
              async: false,
              type: 'POST',
              success: function(data) {
                  eval(data);
  
                  if (window.gameURL) {
                      goingameRaw();
                  }
              }
          });
  
          return false;
      });
  });
  
  function goingameRaw()
  {
      window.open(window.gameURL,'test','left=20,top=20,width=1024,height=640,toolbar=0,resizable=0,location=0');
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Example response body:</p>
  
  <pre><code>window.gameURL="http://mydomain.com/index.php?option=com_pbbgs&amp;format=raw&amp;startgame=618&amp;width=1024&amp;height=640";checktutorial('js','attack');
  </code></pre>