14

I am looking at the API for chrome.contextMenu here.

The context types listed are:

  • "all"
  • "page"
  • "frame"
  • "selection"
  • "link"
  • "editable"
  • "image"
  • "video"
  • "audio"
  • "launcher"
  • "browser_action"
  • "page_action"

Some of these are intuitive, the others not so much.

Where can I find definitions for these different contexts? It is hard to make use of the api without this background knowledge.

Specifically, I would like to know "page", "frame", "editable", and "launcher".

Xan
  • 74,770
  • 16
  • 179
  • 206
pqx994
  • 320
  • 2
  • 14
  • 1. The event names are almost self-descriptive but I haven't seen a complete guide so maybe you should specify which events you want to clarify 2. The page you linked contains all the info: https://puu.sh/iWfEK/83c88da183.png – wOxxOm Jul 12 '15 at 10:58
  • 1. Edited with specific context types. Are context types commonly referred to as event names? 2.The page says the callback parameter should be function(object info), leaving out the optional tab. Can you substitute anything ('clickData') in for 'info' then? Thanks – pqx994 Jul 12 '15 at 11:07
  • The argument name can be any valid identifier name if it's what you ask. – wOxxOm Jul 12 '15 at 11:10
  • Context type, not an event, sorry. And I think you can remove the second question now. – wOxxOm Jul 12 '15 at 11:16
  • Ahh ok, removed the second question. #1 updated – pqx994 Jul 12 '15 at 11:19
  • Hey, I was answering that! wOxxOm, would you _please_ refrain from answering in comments? – Xan Jul 12 '15 at 11:19
  • Okay, I was about to answer, but seeing how the question is mutating I'll wait a couple of hours until it _settles_, I suppose. – Xan Jul 12 '15 at 11:21
  • @Xan, the second question was invalid, why would you want to answer that? – wOxxOm Jul 12 '15 at 11:22
  • @wOxxOm It's a valid beginner-level JS question. – Xan Jul 12 '15 at 11:22
  • You mean not seeing the info on the page linked in his own question? – wOxxOm Jul 12 '15 at 11:23
  • @wOxxOm No, I mean the question is summarized in 2nd comment to this question. That's what I was going to answer. – Xan Jul 12 '15 at 11:23
  • Well, I really thought my first comment was sufficient. Sorry for the confusion. – wOxxOm Jul 12 '15 at 11:25
  • Do either of you have definitions for the context types (#1)? – pqx994 Jul 12 '15 at 20:34

1 Answers1

24
  • "link", "image", "video", "audio" are more or less self-explanatory; they correspond to right-clicks on the appropriate HTML elements.
  • "editable" means a right-click in any text input element (when text is not selected, I think). It can be something obvious like <input>, <textarea> or any tag with content-editable enabled. This question may be of interest.
  • "page" means a right-click on any space on the page that is not covered by the above.
  • "all" is all of the above combined.
  • "frame" is like "all", but only for content within <iframe>s and not the parent document. (source & rationale)
  • "selection" means a right-click on a selected part of text/HTML; a text-only copy of the content will be passed to the callback, and a content script can be used to access the DOM of the selection.
  • "browser_action" and "page_action" populate your icon's context menu when using Browser Actions and/or Page Actions.
  • "launcher" only makes sense for Chrome Apps; it adds context menu entries to the App's shortcut in the App Launcher.
Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • 5
    This should find its place in chrome extension docs. Examples in chrome extension docs are seriously lacking and they are pointing to the sample code of extensions, rather than giving an inline example for usage. – palerdot Nov 08 '16 at 12:56
  • 'all' looks like all including frame, selection, and browser_action – allenhwkim Oct 04 '17 at 17:31