Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

window.NativeWindow.contextmenus.remove

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The NativeWindow object is only available to privileged code running on Firefox for Android, and is intended for use by Firefox for Android add-ons.

Summary

NativeWindow.contextmenus.add() adds an item to the context menu in Firefox for Android, returning an ID for the item. To remove the item, use NativeWindow.contextmenus.remove(), passing in the item's ID.

Syntax

window.NativeWindow.contextmenus.remove(menuID);

menuID
The ID of the item to remove.

Example

The following example adds a new context menu item, stores the ID returned by add(), and later uses that ID to remove the item:

var menuID;  
      
function loadIntoWindow(window) {      
  if (!window)      
    return;  
  let label = "Show HTML";  
  let selector =  window.NativeWindow.contextmenus.SelectorContext("*");  
  menuID = window.NativeWindow.contextmenus.add(label, selector, function(target) {        
    window.NativeWindow.toast.show(target.outerHTML, "short");         
  });      
}      
         
function unloadFromWindow(window) {      
  if (!window)      
    return;      
  window.NativeWindow.contextmenus.remove(menuID);        
}

See Also

Document Tags and Contributors

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