eo_ShowContextMenu Function

Displays a context menu.

Syntax
JavaScript
 function eo_ShowContextMenu(e, menuId)

Parameters

e

The parameter can be a DOM event object or an DHTML element.

When e is a DOM event object, the function uses this paramter to determine the mouse cursor position and use it calculate the position of the of the context menu. This parameter can be null for Microsoft Internet Explorer, but must be provided for all other browsers. For those browsers, DOM event object is the first parameter of the event handling function.

When e is a DHTML element, the function aligns the context menu to the lower-left corner of the DHTML element. The top menu group's OffsetX and OffsetY can also be used to fine tune the final position of the context menu.

menuId
Menu ID. See remarks section for details.

Return Value

Returns false if the context menu has been successively displayed, otherwise true.

The function returns false on success allows you to conveniently display your own popup menu and cancel the default popup menu using one simple statement:

HTML
<div oncontextmenu="return eo_ShowContextMenu(event, 'menu1')">test</div>

Remarks

This function should only be called on a ContextMenu object. Calling it on other type of object would fail.

Usually you can use the ID of the server control as the id parameter to call this function. However, when two server controls resides in different naming containers (for example, two user controls), it's possible for them to have the same ID. In this case you should use the value of the ClientID of the menu control as the id parameter. You may need to use a debugger to find out the ClientID value.

See Also