views:

32

answers:

0

Is it possible to emulate event capturing in Internet Explorer?

An example:

<a>one</a>
<a>two</a>
<a>three3</a>

<script>
var links = document.getElementsByTagName("A");
for (var i=0; i < links.length; i++) {
  links[i].onclick = function(){
    alert("clicked");
  };
}
</script>

I want to prevent all these click events from firing. I can do that with a single event observer:

document.addEventListener("click", function(e) {
    e.stopPropagation();
    e.preventDefault();
}, true);

How can I do the same in IE? IE < 9 does not support addEventListener. It does support attachEvent, but it doesn't have useCapture option.

I've found setCapture method, but it doesn't look related to the W3 capturing model.