Event.preventDefault() (Method)

A means of preventing the default behavior from being activated after the event returns to its dispatcher.

Availability:

DOM level - 2
JavaScript - 1.5
Netscape - 6.0
Opera - 5.0
JavaScript syntax:NmyEvent.preventDefault()

This method only applies if the event can be cancelled. That is, if the Event object's cancelable property contains a true value. This value is readable but not writable. It is defined when the Event object is instantiated or initialized and cannot be changed later.

Calling this method at any time during the handling of the event will cancel the event immediately, returning control to the dispatcher. Any default handling will also be cancelled. You should be aware that if you dispatch an event from a script, it is your responsibility to make sure you check the return status of your dispatch call to ensure you do this consistently with implementation dispatched events.

Calling this method should cancel any subsequent event processing regardless of the kind of propagation being used. Any subsequent bubbling up or capturing should see that the event has been cancelled and should honor that without any further processing of the event.

Calling this method on an event whose cancelable property does not contain a true value should have no effect at all.