SafariExtensionMenu Class Reference
| Technology area | Safari Extensions |
| Availability | Available in Safari 5.1 and later. |
Overview
The SafariExtensionMenu class represents menus.
Properties
identifier
The unique identifier of the menu.
readonly attribute DOMString identifier
Availability
- Available in Safari 5.1 and later.
menuItems
The items in the menu.
readonly attribute array menuItems
Availability
- Available in Safari 5.1 and later.
visible
A Boolean value that indicates whether the menu is currently visible to the user.
readonly attribute boolean visible
Discussion
Changes made to the menu while it is visible to the user are not reflected until the next time it is shown. If the user selects a menu item that was removed after the menu became visible, the menu item’s command is not sent.
Availability
- Available in Safari 5.1 and later.
Methods
appendMenuItem
Creates a menu item and appends it to the menu.
Parameters
- identifier
The unique identifier of the menu item.
- 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 appended.
Discussion
If a menu item with the same identifier already exists, it is removed from before appending the menu item.
Availability
- Available in Safari 5.1 and later.
appendSeparator
Creates a separator menu item and appends it to the menu.
Parameters
- identifier
The unique identifier of the menu item.
Return Value
The menu item that was appended.
Discussion
If a menu item with the same identifier already exists, it is removed from before appending the separator.
Availability
- Available in Safari 5.1 and later.
insertMenuItem
Creates a menu item and inserts it in the menu at the given index.
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.
Availability
- Available in Safari 5.1 and later.
insertSeparator
Creates a separator menu item and inserts it in the menu at the given index.
Parameters
- index
The index at which the menu item is being inserted.
- identifier
The unique identifier of the menu item being inserted.
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 separator.
If the value of index is NaN, Infinity, a negative number, or a number greater than the number of items in the menu, the separator is appended at the end of the menu.
Availability
- Available in Safari 5.1 and later.
removeMenuItem
Removes a menu item.
Parameters
- index
The index of the menu item being removed.
Discussion
Invalid indexes are ignored.
Availability
- Available in Safari 5.1 and later.
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-23)