1 Overview
Preventing bubbling and default events are both very important in js. In fact, it is very simple. Only one or two sentences are required. The key is to be compatible!
2 Stop bubbling events
function stopBubble(e) {
if(e && e.stopPropagation){
e.stopPropagation();
} else {
window.event.cancelBubble = true;
}
};
3 Block default events
function stopDefault(e){
if(e && e.preventDefault) {
e.preventDefault();
} else {
window.event.returnValue = false;
}
return false;
};