avernet
asked on
Prevent onmousedown event from bubbling up in IE
Ok, I think this question is one of the FAQ. But here it is anyway :-). I would like to catch the onmousedown and prevent the browser to interpret it. (I am doing this to display a layer, simulating a contextual menu, where the right mouse button is clicked.)
I have some code that works fine in Netscape, but I can't reproduce the same result with IE. When the event is fired, I set the event.cancelBubble to true, but it doesn't seem to have any effet.
So for instance, how to prevent the browser to go to Yahoo! (and just do nothing instead) when the "Yahoo!" link is clicked in the example below:
<a href="http://www.yahoo.com/">Yahoo!</a>
<script>
document.anchors [0].onmousedown = function () {
event.cancelBubble = true; // This doesn't seem to work.
};
</script>
Alex
I have some code that works fine in Netscape, but I can't reproduce the same result with IE. When the event is fired, I set the event.cancelBubble to true, but it doesn't seem to have any effet.
So for instance, how to prevent the browser to go to Yahoo! (and just do nothing instead) when the "Yahoo!" link is clicked in the example below:
<a href="http://www.yahoo.com/">Yahoo!</a>
<script>
document.anchors [0].onmousedown = function () {
event.cancelBubble = true; // This doesn't seem to work.
};
</script>
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Alex