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 mozbrowsercontextmenu
event is fired when the user tried to access a context menu over a browser <iframe>
. This event can be used to control what will appear in the menu.
CustomEvent
<iframe>
Property | Type | Description |
---|---|---|
target Read only |
EventTarget |
The browser iframe |
type Read only |
DOMString |
The type of event. |
bubbles Read only |
Boolean |
Whether the event normally bubbles or not. |
cancelable Read only |
Boolean |
Whether the event is cancellable or not. |
details Read only |
Object |
A custom object. |
The details
property returns an anonymous JavaScript object with the following properties:
<iframe>
's viewport.<iframe>
's viewport.MenuSystem
objects (see The MenuSystem object, below), containing details of the standard menu(s) that will be shown. For example, if the user clicked on an image nested in an <a>
tag, two menus are available — one with information related to the image, and one for the link.Menu
object (see The Menu object, below) representing a custom menu defined via <menu>
/ <menuitem>
elements and pointed to via a contextmenu
attribute on the DOM element clicked on, which contains the menu
's id
.An object defining a standard context menu that will be displayed. Its properties are as follows:
DOMString
representing the URL of the document the menu is associated with.DOMString
. In the case of an image or video context menu, this is the src
of the image or video clicked on to get the context menu. In the case of an link context menu, it is the link's href
.DOMString
representing the text of the link clicked on, in the case of a link context menu.Boolean
. In the case of a video context menu, this returns true
if the video has metadata and is bigger than 0 x 0, or false
if not.DOMString
representing the action
of a form, in the case of a form context menu.DOMString
representing the method
of a form, in the case of a form context menu.DOMString
representing the name
of a form, in the case of a form context menu.An object representing a custom menu defined via <menu>
/ <menuitem>
elements and pointed to via a contextmenu
attribute on the DOM element clicked on, which contains the menu
's id
. Its properties are as follows:
DOMString
representing the type of context menu displayed. It can be menu
(a full menu) or menuitem (a single menu item.)DOMString
equal to the label
attribute of the DOM node the context menu is accessed on.contextmenuItemSelected()
function, to indicate which item has been selected.Menu
objects, which indicate the menu options available in a menu, if the context menu being accessed is a menu.var browser = document.querySelector("iframe"); browser.addEventListener("mozbrowsercontextmenu", function(event) { console.log("Asking for menu:" + JSON.stringify(event.details)); });
mozbrowserasyncscroll
mozbrowserclose
mozbrowsererror
mozbrowsericonchange
mozbrowserloadend
mozbrowserloadstart
mozbrowserlocationchange
mozbrowseropenwindow
mozbrowsersecuritychange
mozbrowsershowmodalprompt
mozbrowsertitlechange
mozbrowserusernameandpasswordrequired