title: Javascript GET request before window.open prevents target _blank
body: <p>I want to make a click recorder in javascript and then open the requested link in a new tab. Pretty much the same that happens when you click a google search result.</p>
  
  <p>This code is supposed to do it and it almost does it. The only thing is that the window.open is not going to open a new tab. Instead it opens the page in the same tab. If I remove the xmlhttp call from the code then the '_blank' is respected. Why the xmlhttp request before the window.open is preventing the '_blank' to take effect?</p>
  
  <pre><code>recordClick = function(t, id) {
    var clickurl = "http://www.example.com";
    if(clickurl != undefined &amp;&amp; clickurl.length &gt; 0) {
      xmlhttp.open("GET",clickurl,false);
      xmlhttp.send();
    }
    if(id &gt; 0) {
      window.open("http://www.example.com/click/"+id, '_blank');
    } else {
      window.open(t, '_blank');
    }
  }
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>This was easy. Adding <code>var xmlhttp = new XMLHttpRequest();</code> solved it.</p>