title: Is it possible to programmatically catch all events on the page in the browser?
body: <p>First of all, here is a list of event types that are defined by the W3C standards. (This list is based on the onevent attributes defined in the HTML5 standard. I assume that there are dozens of other event types, but this list is long enough as it is.)  </p>
  
  <ul>
  <li>abort</li>
  <li>afterprint</li>
  <li>beforeprint</li>
  <li>beforeunload</li>
  <li>blur</li>
  <li>canplay</li>
  <li>canplaythrough</li>
  <li>change</li>
  <li>click</li>
  <li>contextmenu</li>
  <li>copy</li>
  <li>cuechange</li>
  <li>cut</li>
  <li>dblclick</li>
  <li>DOMContentLoaded</li>
  <li>drag</li>
  <li>dragend</li>
  <li>dragenter</li>
  <li>dragleave</li>
  <li>dragover</li>
  <li>dragstart</li>
  <li>drop</li>
  <li>durationchange</li>
  <li>emptied</li>
  <li>ended</li>
  <li>error</li>
  <li>focus</li>
  <li>focusin</li>
  <li>focusout</li>
  <li>formchange</li>
  <li>forminput</li>
  <li>hashchange</li>
  <li>input</li>
  <li>invalid</li>
  <li>keydown</li>
  <li>keypress</li>
  <li>keyup</li>
  <li>load</li>
  <li>loadeddata</li>
  <li>loadedmetadata</li>
  <li>loadstart</li>
  <li>message</li>
  <li>mousedown</li>
  <li>mouseenter</li>
  <li>mouseleave</li>
  <li>mousemove</li>
  <li>mouseout</li>
  <li>mouseover</li>
  <li>mouseup</li>
  <li>mousewheel</li>
  <li>offline</li>
  <li>online</li>
  <li>pagehide</li>
  <li>pageshow</li>
  <li>paste</li>
  <li>pause</li>
  <li>play</li>
  <li>playing</li>
  <li>popstate</li>
  <li>progress</li>
  <li>ratechange</li>
  <li>readystatechange</li>
  <li>redo</li>
  <li>reset</li>
  <li>resize</li>
  <li>scroll</li>
  <li>seeked</li>
  <li>seeking</li>
  <li>select</li>
  <li>show</li>
  <li>stalled</li>
  <li>storage</li>
  <li>submit</li>
  <li>suspend</li>
  <li>timeupdate</li>
  <li>undo</li>
  <li>unload</li>
  <li>volumechange</li>
  <li>waiting</li>
  </ul>
  
  <p>Now, is it possible to define a global event handler that is called when <strong>any</strong> event originally occurs on <strong>any</strong> element on the page? (In this case, I don't want to count those events that occurred on elements because they bubbled up from a descendant element - that's why I wrote "originally occurs".)</p>
  
  <p>If that is not possible, is it at least possible to define an event handler that is called when <strong>any</strong> event bubbles up to the root of the DOM tree (which is either the <code>document</code> object or the <code>window</code> object - both should work)? (I know that it's possible to stop bubbling programmatically, but I would use this event handler on a page that has no other handlers defined on any other elements.) (Also, I believe some events don't bubble up, but let's ignore these cases for the sake of this argument.)</p>
  
  <p>I know that I can do this (using jQuery): </p>
  
  <pre><code>$(document).bind('abort afterprint beforeprint beforeunload etc.', function() {
      // handle event
  });
  </code></pre>
  
  <p>but that would be a rather undesirable solution for me.</p>
  
  <p>btw I don't need a cross-browser solution. If it works in just one browser, I'm fine.</p>
  
  <p>Also, <a href="https://stackoverflow.com/questions/4089516/view-javascript-events-in-browser/4089542#4089542">Firebug is able to log events</a>, but I would like to be able to catch the event programmatically (via JavaScript) rather then having them simply logged in the console.</p>