mozbrowsercontextmenu 编辑

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

PropertyTypeDescription
target Read onlyEventTargetThe browser iframe
type Read onlyDOMStringThe type of event.
bubbles Read onlyBooleanWhether the event normally bubbles or not.
cancelable Read onlyBooleanWhether the event is cancellable or not.
details Read onlyObjectA 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:30 次

字数:12437

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文