Instantiation Example
The following is an example of the nested DIV structure used to construct a context menu:
<DIV ID='mycontextmenu'
CLASS='bdcontextmenu'
TABINDEX=0
STYLE='DISPLAY: none; BEHAVIOR: url(/widgets/listHTC/menucontrol.htc)'
LANGUAGE=VBScript
ONCLICK='clickContextMenuItem'
ONHIGHLIGHT='toggleContextMenuHighlight'
ONUNHIGHLIGHT='toggleContextMenuHighlight'
ONCLOSE ='closeContextMenu'>
<DIV ID='myopen'
CLASS='bdcontextmenuitem'
LANGUAGE=VBScript
ONCONTEXTCLICK='myOpenHandler'>Open
</DIV>
<DIV ID='mydelete'
CLASS='bdcontextmenuitem'
LANGUAGE=VBScript
ONCONTEXTCLICK='myDeleteHandler'>Delete
</DIV>
</DIV>
The routines myOpenHandler and myDeleteHandler will be run when the user clicks on the corresponding item in the menu.
To attach the above menu to an HTML element on your page simply add the routine showContextMenu to handle the onContext menu event:
<LABEL ID='mylabel'
LANGUAGE=VBScript
ONCONTEXTMENU='showContextMenu'>
Right-clickable text goes here
</LABEL>
For more information about working with context menus, see the reference topics for the following routines:
- clickContextMenuItem (client-side)
- closeContextMenu (client-side)
- showContextMenu (client-side)
- toggleContextMenuHighlight (client-side)
Copyright © 2005 Microsoft Corporation.
All rights reserved.