contextMenus

Add items to the browser's context menu, to be displayed in the contexts you specify. For example, you can show the item only when the user clicks on an image, or on an editable element, or when part of a page is selected.

To use this API you need to have the "contextMenus" permission.

Types

contextMenus.ContextType
The different contexts a menu can appear in. Specifying 'all' is equivalent to the combination of all contexts.
contextMenus.ItemType
The type of menu item.
contextMenus.OnClickData
Information sent when a context menu item is clicked.

Properties

contextMenus.ACTION_MENU_TOP_LEVEL_LIMIT
The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored.

Functions

contextMenus.create()
Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in runtime.lastError).
contextMenus.update()
Updates a previously created context menu item.
contextMenus.remove()
Removes a context menu item.
contextMenus.removeAll()
Removes all context menu items added by this extension.

Events

contextMenus.onClicked
Fired when a context menu item is clicked.

Browser compatibility

EdgeFirefoxChromeOpera
ACTION_MENU_TOP_LEVEL_LIMIT?45.0Yes33
ContextType?45.0Yes33
ItemType?45.0Yes33
OnClickData?45.0Yes33
create?45.0Yes33
onClicked?45.0Yes33
remove?45.0Yes33
removeAll?45.0Yes33
update?45.0Yes33
Firefox
ACTION_MENU_TOP_LEVEL_LIMITNo
ContextTypeNo
ItemTypeNo
OnClickDataNo
createNo
onClickedNo
removeNo
removeAllNo
updateNo

Chrome incompatibilities

None.

Acknowledgements

This API is based on Chromium's chrome.contextMenus API. This documentation is derived from context_menus.json in the Chromium code.

Document Tags and Contributors

 Contributors to this page: wbamberg, andymckay-github
 Last updated by: wbamberg,