Cancel the browser's default behavior (response) to the event (such as tag jump, etc.) and stop the event from continuing to propagate.
Implementation code
function stopEvent (evt ) {
var evt = evt || window.event;
if (evt.preventDefault) {
evt.preventDefault();
evt.stopPropagation();
} else {
evt.returnValue = false;
evt.cancelBubble = true;
}
}
Only prevents the event from continuing to propagate (does not cancel the default behavior)
function stopEvent (evt) {
var evt = evt || window. event;
if (evt.stopPropagation) {
evt.stopPropagation();
} else {
evt.cancelBubble = true;
}
}
Only cancel the default behavior (do not prevent the event from continuing to propagate)
function stopEvent (evt) {
var evt = evt || window.event;
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.returnValue = false;
}
}