Movatterモバイル変換


[0]ホーム

URL:


  1. Mozilla
  2. Add-ons
  3. Browser extensions
  4. JavaScript APIs
  5. menus
  6. menus.removeAll()

menus.removeAll()

Removes all menu items added by the extension.

For compatibility with other browsers, Firefox makes this method available via thecontextMenus namespace as well as themenus namespace.

This is an asynchronous function that returns aPromise.

Syntax

js
let removing = browser.menus.removeAll()

Parameters

None.

Return value

APromise that will be fulfilled with no arguments when all items have been removed.

Examples

This example adds two menu items. When the user clicks the item labeled "Remove all!", the extension removes both items usingremoveAll().

js
function onRemoved() {  console.log("items removed successfully");}browser.menus.create({  id: "click-me",  title: "Click me!",  contexts: ["all"],});browser.menus.create({  id: "remove-all",  title: "Remove all!",  contexts: ["all"],});browser.menus.onClicked.addListener((info, tab) => {  if (info.menuItemId === "remove-all") {    let removing = browser.menus.removeAll();    removing.then(onRemoved);  }});

Browser compatibility

Note:This API is based on Chromium'schrome.contextMenus API. This documentation is derived fromcontext_menus.json in the Chromium code.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp