title: How to use both onclick and ondblclick on an element?
body: <p>I have an element on my page that I need to attach onclick and ondblclick event handlers to.  When a single click happens, it should do something different than a double-click.  When I first started trying to make this work, my head started spinning.  Obviously, onclick will always fire when you double-click.  So I tried using a timeout-based structure like this...</p>
  
  <pre><code>window.onload = function() {
    var timer;
    var el = document.getElementById('testButton');
  
    el.onclick = function() {
      timer = setTimeout(function() { alert('Single'); }, 150);        
    }
  
    el.ondblclick = function() {
      clearTimeout(timer);
      alert('Double');
    }
  }
  </code></pre>
  
  <p>But I got inconsistent results (using IE8).  It would work properly alot of times, but sometimes I would get the "Single" alert two times.</p>
  
  <p>Has anybody done this before?  Is there a more effective way?</p>