title: window.attachEvent to resize a window in IE
body: <p>I want to display picture in a new window. For that I wrote JavaScript function that opens new window. I open a window with some fixed size (for example 500 x 500), but I want to resize my window to picture size. For that I attach event to this newly created window. Here is only code for IE because in Firefox and Chrome all work.</p>
  <pre><code>var win = null;
  function showPicture(url) {
      win = window.open(url, &quot;pic&quot;, &quot;height=500,width=500&quot;);
      if (window.attachEvent) {
          win.attachEvent(&quot;onload&quot;, correctWinSize);  
      }
      // Not IE attach event code
  }
  
  function correctWinSize() {
       // Here is resize code
  }
  </code></pre>
  <p>Problem is that event fires only sometimes. I just click on hyperlink that calls <code>showPicture()</code> and window is sometimes resized and sometimes not. Have you any ideas how to make it work?</p>