title: JavaScript function sometimes called, sometimes not
body: <p>This looks weird... I have an HTML page in which I can't modify the <code>"body"</code> line (because it's php-included from another file). In the file, before the closing <code>"/body"</code> tag, I have a JavaScript function:</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  function doSomething () {
    /* some code */
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Since I want this function to be executed when the page is displayed, and since I can't modify the "body" line, I added somewhere a small image, and called this function when it loads:</p>
  
  <pre><code>&lt;img src="transp.gif" border="0" width="0" height="0" onload="doSomething();" /&gt;
  </code></pre>
  
  <p>Problem is the function is sometimes called and sometimes not called. I even verified this with appropriate <code>"alert"</code> statement... What am I doing wrong? Why isn't the <code>"onload"</code> executing consistently?</p>