General method to stop bubbles:
function stopBubble(e) { //If an event object is provided, it is a non-IE browser if (e && e.stopPropagation ) //Use W3C's stopPropagation() method e.stopPropagation(); else //Use IE's cancelBubble = true to cancel event bubbles window.event.cancelBubble = true; }Block browser default behavior - General method
//Block the default behavior of the browser function stopDefault( e ) { //Block the default browser action (W3C) if ( e && e.preventDefault ) e.preventDefault(); //How to block the default action of the function in IE else window.event.returnValue = false; return false; }Event compatibility
function myfn(e){ var evt = e ? e:window.event; }
js stop bubble compatible
window.event? window.event.cancelBubble = true : evt.stopPropagation();
js blocks default behavior compatibility
window.event? window.event.returnValue = false : evt.preventDefault();
The simple way to stop bubbling and block the default behavior of the browser in the above article is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.