Javascript timer issue
<p>Try to make a timer like following way:</p>

<p><strong>HTML:</strong></p>

<pre><code>&lt;div id="timer"&gt;
     &lt;span id="minute" class="dis"&gt;00&lt;/span&gt; :
     &lt;span id="second" class="dis"&gt;00&lt;/span&gt; :
     &lt;span id="milisecond" class="dis"&gt;00&lt;/span&gt;
 &lt;/div&gt;

 &lt;input type="button" value="Start/Stop" id="startStop" /&gt;
 &lt;input type="button" value="Reset" id="reset" /&gt;
</code></pre>

<p><strong>jQuery:</strong></p>

<pre><code> var a = false,
         t = null,
         ms = 0,
         s = 0,
         m = 0,
         dl = 10,
         now = null,
         before = new Date(),
         El = function(id) { return document.getElementById(id);};

     function dsp() {
         if(ms++ == 99){
              ms = 0;
             if(s++ == 59) {
                 s = 0;
                 m++;
             } else s = s;
         } else ms = ms;    
         El('milisecond').innerHTML = ms
         El('second').innerHTML = s &lt; 10 ? '0' + s : s;
         El('minute').innerHTML = m &lt; 10 ? '0' + m : m;
     }

     function r() {
         a = true;
         var els = document.getElementsByClassName('dis');
         ms = s = m = 0;
         sw();        
         for(var i in els)  {
             els[i].innerHTML = '00';    
         }
     }

     function sw() {
         a ? clearInterval(t) : t = setInterval(dsp, dl);
         a = !a;
     }
     El('startStop').addEventListener('click', sw, true);
     El('reset').addEventListener('click', r, true);
</code></pre>

<p>It works just fine. But problem is that it stop execution when window switch or tab change happen. Before submit this question I read <a href="http://stackoverflow.com/questions/5927284/how-can-i-make-setinterval-also-work-when-a-tab-is-inactive-in-chrome">this thread</a>, but fail to implement it in my snippet. </p>

<p>Please help me with some solution or suggestion..</p>

<p>Here is the <a href="http://jsfiddle.net/XhGeX/4/" rel="nofollow">fiddle</a></p>
