Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

menus.remove()

Removes a menu item.

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.remove(  menuItemId      // integer or string)

Parameters

menuItemId

integer orstring. The ID of the menu item to remove.

Return value

APromise that will be fulfilled with no arguments if removal was successful, or rejected with an error message if removal failed (for example, because the item could not be found).

Examples

This extension adds a menu item labeled "Remove me!". If you click the item, the extension removes it.

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

Example extensions

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