Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

mozbrowsercontextmenu

Nuestros voluntarios aún no han traducido este artículo al Español. Únete a nosotros y ayúdanos a traducirlo

Non-standard
This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

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
target Read only EventTarget The browser iframe
type Read only DOMString The type of event.
bubbles Read only boolean Does the event normally bubble?
cancelable Read only boolean Is it possible to cancel the event?
details Read 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 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.
contextmenu
A 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.
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 DOMString representing 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 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.
text
A DOMString representing 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 returns true if the video has metadata and is bigger than 0 x 0, or false if not.
action
A DOMString representing the action of a form, in the case of a form context menu.
method
A DOMString representing the method of a form, in the case of a form context menu.
name
A DOMString representing the name of 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 DOMString representing the type of context menu displayed. It can be menu (a full menu) or menuitem (a single menu item.)
label
A DOMString equal to the label attribute 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 Menu objects, 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));
});

See also

Etiquetas y colaboradores del documento

 Colaboradores en esta página: chrisdavidmills, teoli, kscarfone, Jeremie
 Última actualización por: chrisdavidmills,