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); }