IE has a Element.setCapture() method that you may find useful http://msdn.microsoft.com/en-us/library/ms536742(v=vs.85).aspx It allows you to route all mouse events to the element that called setCapture()
function myFunction(e) {
if (!e) var e = window.object;//legacy event object
if (e.preventDefault) e.preventDefault();//prevent firing in W3C model
return false; //exit event, no firing, listener must registered to anchor tag
}
var x = document.getElementsByTagName("A");
if (x.item(0).addEventListener) {
for (var i = 0, l = x.length; i < l; i++) {
x.item(i).addEventListener("click",myFunction,false);
}
}//W3C model
else if (x.item(0).attachEvent) {
for (var i = 0, l = x.length; i < l; i++) {
x.item(i).attachEvent("onclick",myFunction);
}
}// legacy browsers
Generally you can't because of the event order. In IE the events will start bubbling from the target element without the capturing phase so you can't catch them beforehand.
There's only one thing you can do, and it's only possible if you manage all the event handlers.
addEvent
with capture parameterIf capturing is required do the following
Array
Array
invoking the original event handler on each of the elements The Uniform Event Model project from JavaScript Lab appears to emulate the capture phase. Go to the download page for the JSLab DOM Correction library and select everything and select the commented format. Then download the code and search it for the word 'capture'. I have not tested the library or read much of its code.
The best way if you use only bubbling for clicks:
if (document.addEventListener) document.addEventListener("click", function(e){e.preventDefault();},false);
else if (document.attachEvent) document.attachEvent("onclick", function(){window.event.returnValue = false;});
setCapture is used to retain some mouse-related action outside the browser window
and it is used to implement some kind of drag&drop
if you mousedown an element and you will go with your pointer outside the browser window the mousemove event stops to work
if you setCapture() the mousemove event will continue to work outside the browser window
https://developer.mozilla.org/en/DOM/element.setCapture
and the related method to release capture
https://developer.mozilla.org/en/DOM/document.releaseCapture
so, it has nothing in common with the capturing event model and, there's no known way to emulate it in internet explorer in a standard way!
hope this helps!