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.removeAll()

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

Removes all context menu items added by this add-on.

Syntax

chrome.contextMenus.removeAll(
  function() {...} // optional function
)

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

Parameters

callbackOptional
function. Called when all items have been removed.

Browser compatibility

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

Examples

This example adds two context menu items. When the user clicks the item labeled "Remove all!", the add-on removes both items using removeAll().

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("All items removed successfully");
  }
}

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

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

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

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.

ドキュメントのタグと貢献者

 このページの貢献者: Makyen, wbamberg
 最終更新者: Makyen,