sidebar_action 编辑

Type Object
Mandatory No
Example
"sidebar_action": {
  "default_icon": {
    "16": "button/geo-16.png",
    "32": "button/geo-32.png"
  },
  "default_title": "My sidebar",
  "default_panel": "sidebar/sidebar.html",
  "open_at_install":true
}
   

A sidebar is a pane that is displayed at the left-hand side of the browser window, next to the web page. The browser provides a UI that enables the user to see the currently available sidebars and to select a sidebar to display.

The sidebar_action key enables you to define the default properties for the sidebar. You can change these properties at runtime using the sidebarAction API.

Syntax

The sidebar_action key is an object that may have any of the properties listed below. The only mandatory property is default_panel.

Name Type Description
browser_style Boolean

Optional, defaulting to true.

Use this to include a stylesheet in your popup that will make it look consistent with the browser's UI and with other extensions that use the browser_style property.

In Firefox, the stylesheet can be seen at chrome://browser/content/extension.css, or chrome://browser/content/extension-mac.css on OS X. When setting dimensions, be aware that this style sheet currently sets box-sizing: border-box (see box-sizing).

The Firefox Style Guide describes the classes you can apply to elements in the sidebar in order to get particular styles.

default_icon Object or String

Use this to specify one or more icons for the sidebar. The icon is shown in the browser's UI for opening and closing sidebars.

Icons are specified as URLs relative to the manifest.json file itself.

You can specify a single icon file by supplying a string here:

"default_icon": "path/to/geo.svg"

To specify multiple icons in different sizes, specify an object here. The name of each property is the icon's height in pixels, and must be convertible to an integer. The value is the URL. For example:

    "default_icon": {
      "16": "path/to/geo-16.png",
      "32": "path/to/geo-32.png"
    }

See Choosing icon sizes for more guidance on this.

This property is optional: if it is omitted, the sidebar doesn't get an icon.

default_panel String

The path to an HTML file that specifies the sidebar's contents.

The HTML file may include CSS and JavaScript files using <link> and <script> elements, just like a normal web page.

Unlike a normal web page, JavaScript running in the panel can access all the WebExtension APIs (subject, of course, to the extension having the appropriate permissions).

This property is mandatory.

This is a localizable property.

default_title String

Title for the sidebar. This is used in the browser UI for listing and opening sidebars, and is displayed at the top of the sidebar when it is open.

This property is optional: if it is omitted, the sidebar's title is the extension's name.

This is a localizable property.

open_at_install Boolean Optional, defaulting to true. Determines whether the sidebar should open on install. The default behavior is to open the sidebar when installation is completed.

Example

"sidebar_action": {
  "default_icon": "sidebar.svg",
  "default_title": "My sidebar!",
  "default_panel": "sidebar.html",
  "browser_style": true
}

For a simple example of an extension that uses a sidebar, see annotate-page.

Browser compatibility

BCD tables only load in the browser

See also

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

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

发布评论

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

词条统计

浏览:90 次

字数:6938

最后编辑:7 年前

编辑次数:0 次

更多

友情链接

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