Preventing browser actions

There are two ways to tell the browser we don’t want it to act:

  • The main way is to use the event object. There’s a method event.preventDefault().
  • If the handler is assigned using on<event> (not by addEventListener), then returning false also works the same.

Returning false from a handler is an exception
The value returned by an event handler is usually ignored.
The only exception is return false from a handler assigned using on<event>.
In all other cases, return value is ignored. In particular, there’s no sense in returning true.