PreventDefault

From Svg wiki

Contents

Description

The preventDefault method stops the UA's default action for this event, if that event is cancellable. In common usage, this can prevent the activation of the right-click context menu.

Warning: In many script implementations, this also seems to cancel the event bubbling, though it is not supposed to. That effect is only supposed to occur with the use of the stopPropagation method (which often also prevents the context menu from activating).

Type

Method

Parameters

None

Methods

None

Return Value

None

Related Methods and Objects

Examples

This example will prevent the context menu from activating, if triggered on click, mousedown, and mouseup events:

function StopMenu( evt )
{
  // if this is a right-click... 
  if ( 2 == evt.button )
  { 
     // ...stop the menu from activating
     evt.preventDefault();
  }
}

Implementation Support

Specification Reference

DOM3 Events