Safari Developer Library

Developer

SafariExtensionContextMenu Class Reference

Options
Deployment Target:

On This Page

SafariExtensionContextMenu

Instances of the SafariExtensionContextMenu class represent a contextual menu that is populated by the extension. Safari displays the contents of this menu as part of its contextual menu. More...

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Not Applicable Not Applicable

Availability


Available in Safari 5.0 and later.
  • Appends a menu item to the contextual menu.

    Declaration

    JavaScript

    SafariExtensionContextMenuItem appendContextMenuItem (in DOMString identifier, in DOMString title, in DOMString command);

    Parameters

    identifier

    The unique identifier of the menu item.

    title

    The title of the menu item.

    command

    The command identifier that the context menu item sends when activated. Optional.

    Return Value

    The context menu item that was appended.

    Discussion

    If another menu item with the same identifier already exists, it is removed before appending the menu item. If command is not supplied, identifier is used as the command identifier.

    Availability

    Available in Safari 5.0 and later.

  • Inserts a menu item at a specific index in the contextual menu.

    Declaration

    JavaScript

    SafariExtensionContextMenuItem insertContextMenuItem (in unsigned int index, in DOMString identifier, in DOMString title, in DOMString command);

    Parameters

    index

    The index where the menu item is being inserted.

    identifier

    The unique identifier of the menu item.

    title

    The title of the menu item.

    command

    The command identifier that the context menu item sends when activated. Optional.

    Return Value

    The context menu item that was inserted.

    Discussion

    If another menu item with the same identifier already exists, it is removed before appending the menu item. If command is not supplied, identifier is used as the command identifier.

    Availability

    Available in Safari 5.0 and later.

  • contextMenuItems Property

    Returns a list of the context menu items from this extension.

    Declaration

    JavaScript

    readonly attribute array contextMenuItems

    Discussion

    Only menu items from your extension are returned.

    Availability

    Available in Safari 5.0 and later.