Instance Method

insertMenuItem

Creates a menu item and inserts it in the menu at the given index.

Declaration

SafariExtensionMenuItem insertMenuItem(in unsigned long index, in DOMString identifier, in DOMString title, in DOMString command);

Parameters

index

The index at which the menu item is being inserted.

identifier

The unique identifier of the menu item being inserted.

title

The title of the menu item.

command

The command identifier to send when the menu item is activated. This parameter is optional; the default value is the menu item’s identifier.

Return Value

The menu item that was inserted.

Discussion

If a menu item with the same identifier already exists, it is removed from before inserting the menu item.

If the value of index is NaN, Infinity, a negative number, or a number greater than the number of items in the menu, the menu item is appended at the end of the menu.

See Also

Adding Menu Items

appendMenuItem

Creates a menu item and appends it to the menu.

appendSeparator

Creates a separator menu item and appends it to the menu.

insertSeparator

Creates a separator menu item and inserts it in the menu at the given index.