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.
General info
- Specification
- Non standard
- Interface
- CustomEvent
- Bubbles
- Yes
- Cancelable
- Yes
- Target
- <iframe>
- Default Action
- None
Properties
| Property | Type | Description | 
|---|---|---|
| targetRead only | EventTarget | The browser iframe | 
| typeRead only | DOMString | The type of event. | 
| bubblesRead only | Boolean | Whether the event normally bubbles or not | 
| cancelableRead only | Boolean | Whether the event is cancellable or not? | 
| detailsRead only | Object | A custom object | 
details
The details property returns an anonymous JavaScript object with the following properties:
- clientX
- The X value of the coordinate that was clicked inside the browser <iframe>'s viewport.
- clientY
- The Y value of the coordinate that was clicked inside the browser <iframe>'s viewport.
- systemTargets
- An array containing one or more MenuSystemobjects (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.
- contextmenu
- A Menuobject (see The Menu object, below) representing a custom menu defined via<menu>/<menuitem>elements and pointed to via acontextmenuattribute on the DOM element clicked on, which contains themenu'sid.
- contextmenuItemSelected
- An anonymous function that fires when a menu item is selected.
The MenuSystem object
An object defining a standard context menu that will be displayed. Its properties are as follows:
- documentURI
- A DOMStringrepresenting the URL of the document the menu is associated with.
- uri
- A DOMString. In the case of an image or video context menu, this is thesrcof the image or video clicked on to get the context menu. In the case of an link context menu, it is the link'shref.
- text
- A DOMStringrepresenting the text of the link clicked on, in the case of a link context menu.
- hasVideo
- A Boolean. In the case of a video context menu, this returnstrueif the video has metadata and is bigger than 0 x 0, orfalseif not.
- action
- A DOMStringrepresenting theactionof a form, in the case of a form context menu.
- method
- A DOMStringrepresenting themethodof a form, in the case of a form context menu.
- name
- A DOMStringrepresenting thenameof a form, in the case of a form context menu.
The Menu object
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:
- type
- A DOMStringrepresenting the type of context menu displayed. It can bemenu(a full menu) or menuitem (a single menu item.)
- label
- A DOMStringequal to thelabelattribute of the DOM node the context menu is accessed on.
- icon
- The menu item's icon, if the context menu being accessed is a menu item.
- id
- The menu item's id, if the context menu being accessed is a menu item. This is passed to the contextmenuItemSelected()function, to indicate which item has been selected.
- items
- An array of further Menuobjects, which indicate the menu options available in a menu, if the context menu being accessed is a menu.
Example
var browser = document.querySelector("iframe");
browser.addEventListener("mozbrowsercontextmenu", function(event) {
  console.log("Asking for menu:" + JSON.stringify(event.details));
});
Related Events
- mozbrowserasyncscroll
- mozbrowserclose
- mozbrowsererror
- mozbrowsericonchange
- mozbrowserloadend
- mozbrowserloadstart
- mozbrowserlocationchange
- mozbrowseropenwindow
- mozbrowsersecuritychange
- mozbrowsershowmodalprompt
- mozbrowsertitlechange
- mozbrowserusernameandpasswordrequired