setContextMenu Method

DHTML, HTML, & CSS

setContextMenu Method


Constructs a context menu that is displayed when a user right-clicks a scriptlet in the scriptlet container object.

Applies To

Scriptlet

Syntax

window.external.setContextMenu( menuDefinition )

Parameters

menuDefinition
Defines the command text and commands contained in the context menu. A one-dimensional array in which the menu items are defined using sequences of two elements, n and n+1.

Element nThe command text. Shortcut keys are defined by preceding a letter with "&".
Element n+1The method to be called when the command is chosen. You cannot pass parameters to the method.

Note   Context menus can only be defined in scripts written in VBScript or JavaScript, because only those languages can create arrays usable by the setContextMenu method.

For example, the following script defines a context menu with three commands:

<SCRIPT LANGUAGE="VBScript" FOR="Menu" EVENT="onClick">
   ' Define array
   dim menuItems(6)     ' 3 commands
   
   ' First menu item
   menuItems(0) = "Display the &time"     ' Command text
   menuItems(1) = "SetTime"

   ' Second menu item
   menuItems(2) = "Display the &date"     ' Command text
   menuItems(3) = "SetDate"

   ' Third menu item
   menuItems(4) = "Display the document t&itle"     ' Command text
   menuItems(5) = "SetTitle"

   ' Assigns the menu to the scriplet
   ' window.external.setContextMenu(menuItems)

</SCRIPT>



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.