There are many default browser actions:
mousedown– starts the selection (move the mouse to select).
<input type="checkbox">– checks/unchecks the input.
submit– clicking an
<input type="submit">or hitting Enter inside a form field causes this event to happen, and the browser submits the form after it.
keydown– pressing a key may lead to adding a character into a field, or other actions.
contextmenu– the event happens on a right-click, the action is to show the browser context menu.
- …there are more…
To prevent a default action – use either
return false. The second method works only for handlers assigned with
passive: true option of
addEventListener tells the browser that the action is not going to be prevented. That’s useful for some mobile events, like touchstart and touchmove, to tell the browser that it should not wait for all handlers to finish before scrolling.
If the default action was prevented, the value of
true, otherwise it’s
Use the share button below if you liked it.
It makes me smile, when I see it.