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;
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn