阻止向上一级冒泡:
- function stopBubble(e) {
- if ( e && e.stopPropagation ) e.stopPropagation();
- else window.event.cancelBubble = true;
- }
阻止向下一级冒泡:
<p οnclick=”test(this,event)”></p>
- function test(o,evt){
- var e = (evt.target) ? evt.target : event.srcElement;
- if(o == e){
- ....
- }
- }
阻止浏览器默认行为:
- function stopDefault(e) {
- if ( e && e.preventDefault ) e.preventDefault();
- else window.event.returnValue = false;
- }
http://blog.xhlv.com/index.php/2008/10/20/stop-event-bubbling/