I want to do event delegation and capture all events happening on a DOM object by an event handler bound to the entire document. Is there any difference between binding the events to window
as in:
window.addEventListener(event, function(e){
var obj = e.target;
... // if `obj` is a certain kind of object, then do something
}, false);
and window.document
as in the following?
window.document.addEventListener(event, function(e){
var obj = e.target;
... // if `obj` is a certain kind of object, then do something
}, false);
event
is some kind of event like 'click'
, 'mouseover'
, etc.