title: Javascript onload function is not defined
body: <p>Here is the code:</p>
  
  <pre><code>function getTime(j){
    var stopClock= new Date();
    delta[parseInt(j)]=stopClock.getMilliseconds()-start.getMilliseconds();
   }
  
   //REST OF THE CODE!!
  
  for (var i = 0; i &lt; 6; i++){
    start = new Date();
    document.write('&lt;img src="'+URL[i]+'" width="1" height="1" alt="" onload="getTime('+i+');"/&gt;');
   }
  </code></pre>
  
  <p>the problem is sometimes in some values of j (e.g. 3 or 5) it says getTime is not defined! (most of the time is fine)...</p>
  
  <p>I know the it may be because of the fact that when it reaches to that onload line it may not have loaded getTime function yet, but getTime function is at the top of the code and many of the getTime has response...</p>