Cancels the browser's default behavior (response) to the event (such as the <a> tab's jump, etc.) and stops the continuation of the event propagation.
Implementation code
Copy Code code as follows:
function Stopevent (evt) {
var evt = evt | | window.event;
if (Evt.preventdefault) {
Evt.preventdefault ();
Evt.stoppropagation ();
} else {
Evt.returnvalue = false;
Evt.cancelbubble = true;
}
}
Prevent events from continuing to propagate only (do not cancel the default behavior)
Copy Code code as follows:
function Stopevent (evt) {
var evt = evt | | window.event;
if (evt.stoppropagation) {
Evt.stoppropagation ();
} else {
Evt.cancelbubble = true;
}
}
Cancels the default behavior only (does not prevent the event from continuing propagation)
Copy Code code as follows:
function Stopevent (evt) {
var evt = evt | | window.event;
if (Evt.preventdefault) {
Evt.preventdefault ();
} else {
Evt.returnvalue = false;
}
}