🔰default action
browser ⟩ event ⟩ default action
Many events have a default action associated with them.
event handlers are usually called before the default behavior takes place.
call event.preventDefault() to prevent this normal behavior.
// ⭐️ prevent touch screen default actions.
container.addEventListener("touchmove", event => {
event.preventDefault();
}, {passive: false} ); // ⭐️ important
Depending on the browser, some events can’t be intercepted at all. for example:
Chrome:
ctrl+W
orcmd+W
(close current tab) cannot be handled by JavaScript.
Last updated
Was this helpful?