title: window.open image resize jquery
body: <p>hi i am trying to create html popup of an image of perfect size but it only works second time.</p>
  
  <p>for example, when you click an image, it will open without perfect size and if you close it and open it again, it works!</p>
  
  <p>please debug my code:</p>
  
  <pre><code>$(function() {
      $("a.popup3").click(function(){
  
          var asrc = $(this).attr("href");
  
          var image = new Image();
          image.src = asrc;
  
          window.open(image.src,"Image","width="+image.width+",height="+image.height);
          alert(image.src+"adfaSDF"+image.width);
  
          return false;   
      });
  });
  </code></pre>
  
  <p>and the html is like:</p>
  
  <pre><code>&lt;a class="popup3" href="http://localhost/wp/wp-content/uploads/2014/12/Eccles_leaving.jpg"&gt;
     &lt;img class="alignnone wp-image-196" src="http://localhost/wp/wp-content/uploads/2014/12/Eccles_leaving-300x200.jpg" alt="Eccles_leaving" width="220" height="147"&gt;
  &lt;/a&gt;
  </code></pre>