页面操作和浏览器操作之间有什么区别? [英] What are the differences between page action and browser action?

查看:93
本文介绍了页面操作和浏览器操作之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个浏览器动作,但是我只是尝试测试一个页面动作.该按钮放置在同一位置,但是无法单击页面操作按钮(该图标为灰色).我认为页面操作按钮位于地址栏上,而不是在工具栏中.为什么它位于同一地方?

I made a browser action, but I just tried testing a page action. The button is put in the same place, but the page action button can't be clicked (the icon is greyed-out). I thought page action buttons were located on the address bar, not in the toolbar. Why is it located in the same place?

我的浏览器操作按钮:

My browser action button:

我的页面操作按钮:

My page action button:

推荐答案

浏览器操作"和页面操作"按钮均位于地址栏的右侧",如扩展API文档中所述.两种类型的按钮有很多相似之处.使用哪个很大程度上取决于您的扩展程序是否打算在大多数时间都可用,或者仅在一小部分页面上使用.

Both Browser Action and Page Action buttons are located "to the right of the address bar", as described in the Extension API documentation. The two types of buttons have a lot of similarities. Which to use depends largely on if your extension is intended to be usable most of the time, or just on a small subset of pages.

浏览器操作按钮用于在大多数时间或大多数页面上可以使用您的扩展程序时使用.通过使徽章的图标上包含几个/几个字符,并更改用于该徽章的背景颜色,它们还允许您向用户提供一些立即可见的状态信息.

Browser Action buttons are intended to be used when your extension can be used most of the time, or on most pages. They also allow you to provide some immediately visible status information to the user by having a badge containing a couple/few characters over the icon and changing the color of the background used for that badge.

页面操作按钮适用于您的扩展程序经常/通常不可用的情况.例如,如果仅在几个域或URL上可用.

Page Action buttons are intended for use when your extension is often/usually not available for use. For instance, if it's only usable on a few domains or URLs.

浏览器操作按钮应该在大多数时间(大多数页面上)有效或在活动选项卡中显示的页面不相关/不依赖于该按钮时才有效. 默认情况下,所有选项卡/URL上都启用浏览器操作按钮.您必须调用browserAction.disable()来禁用要禁用(或通常在所有选项卡上禁用)的每个选项卡中的按钮.选项卡显示其他URL时,浏览器操作按钮不会更改启用/禁用状态.

Browser action buttons should be used when your button is valid for use most of the time, either on most pages, or not related to/dependent upon the page that is being displayed in the active tab. By default, browser action buttons are enabled on all tabs/URLs. You have to call browserAction.disable() to disable the button in each tab where you want it disabled (or generally disabled on all tabs). The browser action button does not change enabled/disabled state when the tab displays a different URL.

Chrome浏览器的浏览器操作按钮页面说(有些是我的强调):

Chrome's browser action button page says (some emphasis mine):

使用浏览器操作将图标放置在地址栏右侧 的Google Chrome浏览器主工具栏中.除了其图标之外,浏览器操作还可以具有徽章,以及弹出窗口.

Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.

  • 执行对大多数页面有意义的功能使用浏览器操作.
  • 请勿将浏览器操作用于仅对几个页面有意义的功能. 改为使用页面操作.
  • 执行使用大而色彩丰富的图标,充分利用16x16浸入空间.浏览器动作图标看起来应该比页面动作图标更大和更重.
  • 请勿尝试模仿Google Chrome浏览器的单色菜单图标.不适用于主题,无论如何,扩展应该有点突出.
  • 执行使用Alpha透明度为图标添加柔和的边缘.由于许多人使用主题,因此您的图标在各种背景颜色下都应该看起来不错.
  • 不要不断为您的图标设置动画.真烦人.
  • Do use browser actions for features that make sense on most pages.
  • Don't use browser actions for features that make sense for only a few pages. Use page actions instead.
  • Do use big, colorful icons that make the most of the 16x16-dip space. Browser action icons should seem a little bigger and heavier than page action icons.
  • Don't attempt to mimic Google Chrome's monochrome menu icon. That doesn't work well with themes, and anyway, extensions should stand out a little.
  • Do use alpha transparency to add soft edges to your icon. Because many people use themes, your icon should look nice on a variety of background colors.
  • Don't constantly animate your icon. That's just annoying.

浏览器操作具有以下API:

Browser actions have the following APIs:

  • 类型
    • Types
      • ColorArray
      • ImageDataType1
      • 禁用-browserAction.disable(integer tabId)
      • 启用-browserAction.enable(integer tabId)
      • getBadgeBackgroundColor -browserAction.getBadgeBackgroundColor(object details, function callback)
      • getBadgeText -browserAction.getBadgeText(object details, function callback)
      • getPopup 1 -browserAction.getPopup(object details, function callback)
      • getTitle 1 -browserAction.getTitle(object details, function callback)
      • setBadgeBackgroundColor -browserAction.setBadgeBackgroundColor(object details)
      • setBadgeText -browserAction.setBadgeText(object details)
      • setIcon 1 -browserAction.setIcon(object details, function callback)
      • setPopup 1 -browserAction.setPopup(object details)
      • setTitle 1 -browserAction.setTitle(object details)
      • disable − browserAction.disable(integer tabId)
      • enable − browserAction.enable(integer tabId)
      • getBadgeBackgroundColor − browserAction.getBadgeBackgroundColor(object details, function callback)
      • getBadgeText − browserAction.getBadgeText(object details, function callback)
      • getPopup1browserAction.getPopup(object details, function callback)
      • getTitle1browserAction.getTitle(object details, function callback)
      • setBadgeBackgroundColor − browserAction.setBadgeBackgroundColor(object details)
      • setBadgeText − browserAction.setBadgeText(object details)
      • setIcon1browserAction.setIcon(object details, function callback)
      • setPopup1browserAction.setPopup(object details)
      • setTitle1browserAction.setTitle(object details)

      页面操作按钮某些条件或某些URL). 默认情况下,所有URL上的页面操作按钮均被禁用/变灰(隐藏").您必须调用pageAction.show()来为要启用的每个URL/选项卡启用该按钮.如果选项卡显示其他URL,则页面操作按钮会自动变为禁用/隐藏状态.

      Page action buttons should be used when the ability to use of your extension's button is dependent on the URL being shown in the active tab and when it is usually not available for use (i.e. only usable under some conditions, or on some URLs). By default, page action buttons are disabled/grayed out ("hidden") on all URLs. You have to call pageAction.show() to enable the button for each URL/tab you want it enabled. The page action button automatically becomes disabled/hidden if the tab displays a different URL.

      Chrome浏览器的页面操作按钮页面说(有些是我的强调):

      Chrome's page action button page says (some emphasis mine):

      使用chrome.pageAction API将图标放置在Google Chrome浏览器主工具栏中,该工具栏位于地址栏右侧的 .页面操作表示可以在当前页面上执行的操作,但不适用于所有页面.闲置时,页面操作会显示为灰色.

      Use the chrome.pageAction API to put icons in the main Google Chrome toolbar, to the right of the address bar. Page actions represent actions that can be taken on the current page, but that aren't applicable to all pages. Page actions appear grayed out when inactive.

      与浏览器操作一样,页面操作可以具有图标,工具提示和弹出窗口;但是他们不能有徽章.此外,页面操作可以显示为灰色.您可以通过阅读有关浏览器操作界面的信息来找到有关图标,工具提示和弹出窗口的信息.

      Like browser actions, page actions can have an icon, a tooltip, and popup; they can't have badges, however. In addition, page actions can be grayed out. You can find information about icons, tooltips, and popups by reading about the browser action UI.

      使用 pageAction.show 和 pageAction.hide 方法.默认情况下,页面操作显示为灰色.显示它时,您指定应在其中显示图标的选项卡.该图标将保持可见状态,直到关闭选项卡或开始显示其他URL(例如,由于用户单击链接).

      You make a page action appear and be grayed out using the pageAction.show and pageAction.hide methods, respectively. By default, a page action appears grayed out. When you show it, you specify the tab in which the icon should appear. The icon remains visible until the tab is closed or starts displaying a different URL (because the user clicks a link, for example).

      • 对仅有几页有意义的功能使用页面操作.
      • 请勿对大多数页面有意义的功能使用页面操作.代替使用浏览器操作.
      • 不要不断为您的图标设置动画.真烦人.
      • Do use page actions for features that make sense for only a few pages.
      • Don't use page actions for features that make sense for most pages. Use browser actions instead.
      • Don't constantly animate your icon. That's just annoying.

      页面操作具有以下API:

      Page actions have the following APIs:

      • 类型
        • Types
          • ImageDataType1
          • getPopup 1 -pageAction.getPopup(object details, function callback)
          • getTitle 1 -pageAction.getTitle(object details, function callback)
          • 隐藏-chrome.pageAction.hide(integer tabId)
          • setIcon 1 -pageAction.setIcon(object details, function callback)
          • setPopup 1 -pageAction.setPopup(object details)
          • setTitle 1 -pageAction.setTitle(object details)
          • 显示-pageAction.show(integer tabId)
          • getPopup1pageAction.getPopup(object details, function callback)
          • getTitle1pageAction.getTitle(object details, function callback)
          • hide − chrome.pageAction.hide(integer tabId)
          • setIcon1pageAction.setIcon(object details, function callback)
          • setPopup1pageAction.setPopup(object details)
          • setTitle1pageAction.setTitle(object details)
          • show − pageAction.show(integer tabId)

          1.此API可用于浏览器操作和页面操作.两者基本上都做同样的事情.

          这篇关于页面操作和浏览器操作之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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