title: HTML5 WebWorkers, timed function
body: <p>I am trying to get a WebWorker to count to 100 and update a div with the value of I, currently the div just updates straight to 100 and seems to ignore the interval....<br/><br/>
  <strong>JavaScript (webworker file):</strong></p>
  
  <pre><code> self.addEventListener('message', function (e) {
  
          switch (e.data) {
  
              case 'Hi Worker':
                  postMessage('Hi Boss');
                  break
  
              case 'Count to 100':
                  var i;
                  for (i = 0; i &lt; 100; i++) {
                      setInterval(postMessage(i + 1), 1000);
                  }
  
                  break;
              default:
                  self.postMessage("Not sure how to help with that");
          }
  
      }, false);
  </code></pre>
  
  <p><strong>Main file:</strong></p>
  
  <pre><code>           &lt;script&gt;
              var worker = new Worker('worker.js');
  
              worker.addEventListener('message', function (e) {
                  console.log("worker said: " + "'" + e.data + "'");
                  document.getElementById("workerComms").textContent = "worker said: " + e.data;
              }, false);       
  
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;button onclick="worker.postMessage('Hi Worker');return false;"&gt;Say 'Hi Worker'&lt;/button&gt;
              &lt;button onclick="worker.postMessage('Count to 100');return false;"&gt;Count to 100&lt;/button&gt;
  
              &lt;div id="workerComms"&gt;Things workers say...&lt;/div&gt;
  </code></pre>