title: Firefox resets Javascript's variable's value
body: <p>I'm using Firefox 16.0.2.<br>
  I'm using an onload eventlistener to call a script which increases the value of a variable.<br>
  I need to get the variable's value before I increase it. Safari and  Chrome (Webkit) give the right result but Firefox always alerts "0"...  </p>
  
  <p><strong>This is my Script:</strong>  </p>
  
  <pre><code>var obj = {
      build: function() {
          var progressCount = 0; 
          var otherFunction = function(number) {
                  alert(number);
          } 
          var finalFunction = function() {
                  alert("done");
          } 
          var progress = function() {
                  alert(progressCount);   //    !  very important line !
                  progressCount++;
                  otherFunction(progressCount);
                  if (progressCount == ARRAY.length) {
                  finalFunction();
                  }
          }
          ARRAY=document.getElementsByClassName("picture")
          for (var i = 0; i &lt; ARRAY.length; i++)
          ARRAY[i].addEventListener("load", progress);
      }
  }
  obj.build();
  </code></pre>
  
  <p>What else could I try?
  Thank you very much!</p>