[CODE]
<!doctype html>
<html lang=”en”>
<head></head>
<body>
<script>
var calledEvent;
function stop(event)
{
alert( “Stopping” );
event.stopPropagation();
event.preventDefault();
calledEvent = event;
}
function notStopped(event)
{
alert( “Not Stopped: ” + ( event == calledEvent ) );
}
function addEvent(target, eventName, eventListener, stopBubbling)
{
if ( target.addEventListener ) target.addEventListener( eventName, eventListener, stopBubbling );
else if ( target.attachEvent ) return target.attachEvent( “on” + eventName, eventListener );
}
addEvent( document.body, “click”, stop );
addEvent( document.body, “click”, notStopped );
</script>
</body>
</html>
The above code results in the the alerts:
“Stopping”
“Not Stopped: true”
So if it’s the same event, and they’re called in the right order, why isn’t it stopping propagation?