It is suggested to create a function called stopEvent:
function stopEvent(ev){
var e = ev? ev : window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return false;
}
This function would allow us to replace all instances of code like:
e.cancelBubble = true;
if(e.stopPropagation) e.stopPropagation();
with
stopEvent(e);
I've tested this on FF2, IE6 and IE7 and it works well.
Including the line var e = ev? ev : window.event; and returning false means that you can assign this function directly as the onclick or ondblclick for any DOM element where all click events should be prevented from bubbling.
document.getElementById("dontAllowDoubleClick").ondblclick = stopEvent;