Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

contextMenus.remove()

Removes a context menu item.

Syntax

chrome.contextMenus.remove(
  menuItemId,      // integer or string
  function() {...} // optional function
)

This API is also available as browser.contextMenus.remove() in a version that returns a promise.

Parameters

menuItemId
integer or string. The ID of the context menu item to remove.
callbackOptional
function. Called when the context menu has been removed. If the item could not be found or some other error occurs, runtime.lastError will be set, and you can check for it in this function.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 48.0 No 33

Examples

This add-on adds a context menu item labeled "Remove me!". If you click the item, the add-on removes it.

function onCreated() {
  if (chrome.runtime.lastError) {
    console.log("error creating item:" + chrome.runtime.lastError);
  } else {
    console.log("item created successfully");
  }
}

function onRemoved() {
  if (chrome.runtime.lastError) {
    console.log("error removing item:" + chrome.runtime.lastError);
  } else {
    console.log("item removed successfully");
  }
}

chrome.contextMenus.create({
  id: "remove-me",
  title: "Remove me!",
  contexts: ["all"]
}, onCreated);

chrome.contextMenus.onClicked.addListener(function(info, tab) {
  if (info.menuItemId == "remove-me") {
    chrome.contextMenus.remove(info.menuItemId, onRemoved);
  }
});

Example add-ons

Acknowledgements

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

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Makyen, wbamberg
 Last updated by: Makyen,