Chrome内容菜单API上下文类型 [英] Chrome contextMenus API ContextType

查看:318
本文介绍了Chrome内容菜单API上下文类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看API的 chrome.contextMenu 这里



列出的上下文类型包括:


  • all

  • page

  • frame

  • 选择 b $ b
  • link

  • 可编辑

  • 图片

  • 音频

  • 启动器

  • browser_action b
  • page_action



其中一些比较直观,其他则不多。

我在哪里可以找到这些不同上下文的定义?



具体来说,我想知道页面,框架,可编辑和发射。 或多或少是不言自明的;它们对应于在适当的HTML元素上单击鼠标右键。

  • 可编辑意味着在任何文本输入元素中右击(当我选择文本时,我认为)。它可以是< input> < textarea> 之类的显而易见的东西,或者是启用了内容编辑功能的任何标签。 这个问题可能会引起您的兴趣。

  • page指右击在上面覆盖的 页面上的任何空间上。
  • 全部是以上所有组合。

  • frame与all类似,但仅适用于< iframe> s内的内容,而不是父文档。 (source& rationale)

  • 选择表示右键单击文本/ HTML的选定部分;内容的纯文本副本将传递给回调函数,并且可以使用内容脚本访问选择的DOM <内容脚本当使用
  • browser_action和page_action填充图标的上下文菜单rel = noreferrer>浏览器操作和/或页面操作

  • 启动程序仅适用于Chrome应用程序;它会将上下文菜单条目添加到应用程序启动器中的应用程序快捷方式中。


  • 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".

    解决方案

    • "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.

    这篇关于Chrome内容菜单API上下文类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆