You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
paramName
( optional Type array of paramType )
Undocumented.
Description of this parameter from the json schema.

Google Chrome Extensions (Labs)

chrome.experimental.contextMenu

For information on how to use experimental APIs, see the chrome.experimental.* APIs page.

API reference: chrome.experimental.contextMenu

Methods

create

void chrome.experimental.contextMenu.create(, object createProperties, function callback)

An API to add items to context menus.

Parameters

createProperties
( Type array of object )
Undocumented.
Description of this parameter from the json schema.
type
( optional Type array of string )
The type of menu item - one of 'NORMAL', 'CHECKBOX', 'RADIO', or 'SEPARATOR'. Defaults to 'NORMAL' if not specified.
title
( optional Type array of string )
This must be specified unless type is 'SEPARATOR'.
checked
( optional Type array of boolean )
For items of type CHECKBOX or RADIO, should this be selected (RADIO) or checked (CHECKBOX)? Only one RADIO item can be selected at a time in a given group of RADIO items, with the last one to have checked == true winning.
contexts
( optional Type array of Type array of string paramType )
List of contexts this menu item will appear in. Legal values are: 'ALL', 'PAGE', 'SELECTION', 'LINK', 'EDITABLE', 'IMAGE', 'VIDEO', and 'AUDIO'. Defaults to ['PAGE'].
enabledContexts
( optional Type array of Type array of string paramType )
By default the values you pass for the contexts parameter make an item both shown and selectable in those contexts. If you want to limit the contexts where an item is selectable (i.e. not greyed out), you put the ones you want selectable in enabledContexts and any not listed will be shown but disabled. So, for example, if you wanted an item to appear for links and images but only be enabled for links, you would set 'contexts' : ['LINK', 'IMAGE'] and 'enabledContexts' : ['LINK'].
onclick
( optional Type array of function )
Function to be called back when your menu item or one of its children is clicked.
parentId
( optional Type array of integer )
The id of a parent menu item - this makes the item a child of a previously added item.
callback
( optional Type array of function )
Undocumented.
Description of this parameter from the json schema.

Returns

Callback function

The callback parameter should specify a function that looks like this:

If you specify the callback parameter, it should specify a function that looks like this:

function(integer menuItemId) {...});
menuItemId
( Type array of integer )
The id of the newly created context menu item.

remove

void chrome.experimental.contextMenu.remove(, integer menuItemId, function callback)

Remove a context menu item.

Parameters

menuItemId
( Type array of integer )
The id of the context menu item to remove.
callback
( optional Type array of function )
Called when the context menu has been removed.

Returns

Callback function

The callback parameter should specify a function that looks like this:

If you specify the callback parameter, it should specify a function that looks like this:

function() {...});

removeAll

void chrome.experimental.contextMenu.removeAll(, function callback)

Remove all context menu items added by this extension.

Parameters

callback
( optional Type array of function )
Called when removal is complete.

Returns

Callback function

The callback parameter should specify a function that looks like this:

If you specify the callback parameter, it should specify a function that looks like this:

function() {...});

update

void chrome.experimental.contextMenu.update(, integer id, object updateProperties, function callback)

Update a previously created context menu item.

Parameters

id
( Type array of integer )
The id of the item to update.
updateProperties
( Type array of object )
The properties to update. Accepts the same values as the create function.
type
( optional Type array of string )
Undocumented.
Description of this parameter from the json schema.
title
( optional Type array of string )
Undocumented.
Description of this parameter from the json schema.
checked
( optional Type array of boolean )
Undocumented.
Description of this parameter from the json schema.
contexts
( optional Type array of Type array of string paramType )
Undocumented.
Description of this parameter from the json schema.
enabledContexts
( optional Type array of Type array of string paramType )
Undocumented.
Description of this parameter from the json schema.
onclick
( optional Type array of function )
Undocumented.
Description of this parameter from the json schema.
parentId
( optional Type array of integer )
Note: you cannot change an item to be a child of one of it's own descendants.
callback
( optional Type array of function )
Called when the context menu has been updated.

Returns

Callback function

The callback parameter should specify a function that looks like this:

If you specify the callback parameter, it should specify a function that looks like this:

function() {...});