取消冒泡:

w3c的方法是e.stopPropagation,IE为e.cancelBubble = true
window.event ? window.event.cancelBubble = true : e.stopPropagation

取消默认:

w3c的方法是e.prcentDefault(),IE为e.returnValue = false
return false;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<script>
function stopBubble (e) {
if(e && e.stopPropagation) {
e.stopPropagation();
} else {
window.event.cancelBubble = true;
}
}
function stopDefault (e) {
if(e && e.prventDefault) {
e.prventDefault();
} else {
window.event.returnValue = false;
return false;
}
}
</script>