• Skip to main content
  • Select language
  • Skip to search
mozilla
Mozilla Developer Network
  • Sign in
    • Persona
    • GitHub
  • Web Platform
    Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • APIs / DOM
    • Apps
    • MathML
    References & Guides
    • Learn the Web
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • ...more docs
  • Mozilla Docs
    • Add-ons
    • Firefox
    • Firefox Marketplace
    • Firefox OS
    • Persona
  • Developer Tools
  • Feedback
    • Get Firefox help
    • Get web development help
    • Join the MDN community
    • Report a content problem
    • Report a bug
  •  
Add-ons
    • No translations exist for this article.
    • Add a translation
  • Edit
  • Advanced
    • History
    • Print this article
  1. MDN
  2. Mozilla
  3. Add-ons
  4. WebExtensions
  5. JavaScript APIs
  6. tabs
Your Search Results

    tabs

    In This Article
    1. Types
    2. Properties
    3. Functions
    4. Events
    5. Browser compatibility
      1. Chrome incompatibilities
    6. Example add-ons

    Interact with the browser's tab system. You can use this API to get a list of opened tabs and to create, modify, and rearrange tabs in the browser.

    You can use most of this API without any special permission. However, to access Tab.url, Tab.title, and Tab.faviconUrl, you need to have the "tabs" permission. In Firefox this also means you need "tabs" to query by URL.

    TypesEdit

    tabs.MutedInfoReason
    An event that caused a muted state change.
    tabs.MutedInfo
    Tab muted state and the reason for the last state change.
    tabs.Tab
    Contains various properties of a single tab.
    tabs.ZoomSettingsMode
    Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to automatic.
    tabs.ZoomSettingsScope
    Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise.
    tabs.ZoomSettings
    Defines how zoom changes in a tab are handled and at what scope.
    tabs.TabStatus
    Whether the tabs have completed loading.
    tabs.WindowType
    The type of window.

    PropertiesEdit

    tabs.TAB_ID_NONE
    An ID which represents the absence of a browser tab.

    FunctionsEdit

    tabs.get()
    Retrieves details about the specified tab.
    tabs.getCurrent()
    Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view).
    tabs.connect()
    Connects to the content script(s) in the specified tab. The runtime.onConnect event is fired in each content script running in the specified tab for the current extension. For more details, see content script messaging.
    tabs.sendRequest()
    Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The extension.onRequest event is fired in each content script running in the specified tab for the current extension.
    tabs.sendMessage()
    Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage event is fired in each content script running in the specified tab for the current extension.
    tabs.getSelected()
    Gets the tab that is selected in the specified window.
    tabs.getAllInWindow()
    Gets details about all tabs in the specified window.
    tabs.create()
    Creates a new tab.
    tabs.duplicate()
    Duplicates a tab.
    tabs.query()
    Gets all tabs that have the specified properties, or all tabs if no properties are specified.
    tabs.highlight()
    Highlights the given tabs.
    tabs.update()
    Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
    tabs.move()
    Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
    tabs.reload()
    Reload a tab.
    tabs.remove()
    Closes one or more tabs.
    tabs.detectLanguage()
    Detects the primary language of the content in a tab.
    tabs.captureVisibleTab()
    Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
    tabs.executeScript()
    Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
    tabs.insertCSS()
    Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
    tabs.setZoom()
    Zooms a specified tab.
    tabs.getZoom()
    Gets the current zoom factor of a specified tab.
    tabs.setZoomSettings()
    Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
    tabs.getZoomSettings()
    Gets the current zoom settings of a specified tab.

    EventsEdit

    tabs.onCreated
    Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.
    tabs.onUpdated
    Fired when a tab is updated.
    tabs.onMoved
    Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see tabs.onDetached.
    tabs.onSelectionChanged
    Fires when the selected tab in a window changes.
    tabs.onActiveChanged
    Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to tabs.onUpdated events to be notified when a URL is set.
    tabs.onActivated
    Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.
    tabs.onHighlightChanged
    Fired when the highlighted or selected tabs in a window changes.
    tabs.onHighlighted
    Fired when the highlighted or selected tabs in a window changes.
    tabs.onDetached
    Fired when a tab is detached from a window, for example because it is being moved between windows.
    tabs.onAttached
    Fired when a tab is attached to a window, for example because it was moved between windows.
    tabs.onRemoved
    Fired when a tab is closed.
    tabs.onReplaced
    Fired when a tab is replaced with another tab due to prerendering or instant.
    tabs.onZoomChange
    Fired when a tab is zoomed.

    Browser compatibilityEdit

    • Desktop
    • Mobile
    EdgeFirefoxChromeOpera
    MutedInfo?47.0Yes33
    MutedInfoReason?47.0Yes33
    TAB_ID_NONE?45.0Yes33
    Tab?45.0Yes33
    TabStatus?45.0Yes33
    WindowType?45.0Yes33
    ZoomSettings?45.0Yes33
    ZoomSettingsMode?45.0Yes33
    ZoomSettingsScope?45.0Yes33
    captureVisibleTab?47.0Yes33
    connect?45.0Yes33
    create?45.01Yes33
    detectLanguage?45.0Yes33
    duplicate?47.0Yes33
    executeScript?43.0Yes33
    get?45.0Yes33
    getAllInWindow?45.0YesNo
    getCurrent?45.0Yes33
    getSelected?NoYesNo
    getZoom?45.0Yes33
    getZoomSettings?45.0Yes33
    highlight?45.0YesNo
    insertCSS?47.0Yes33
    move?46.0Yes33
    onActivated?45.0Yes33
    onActiveChanged?NoYesNo
    onAttached?45.0Yes33
    onCreated?45.0Yes33
    onDetached?45.0Yes33
    onHighlightChanged?NoYesNo
    onHighlighted?45.0YesNo
    onMoved?45.0Yes33
    onRemoved?45.0Yes33
    onReplaced?45.0Yes33
    onSelectionChanged?NoYesNo
    onUpdated?45.0Yes33
    onZoomChange?45.0Yes33
    query?45.0Yes33
    reload?45.0Yes33
    remove?45.0Yes33
    sendMessage?45.0Yes33
    sendRequest?NoYesNo
    setZoom?45.0Yes33
    setZoomSettings?45.0Yes33
    update?45.02Yes33
    Firefox
    MutedInfoNo
    MutedInfoReasonNo
    TAB_ID_NONENo
    TabNo
    TabStatusNo
    WindowTypeNo
    ZoomSettingsNo
    ZoomSettingsModeNo
    ZoomSettingsScopeNo
    captureVisibleTabNo
    connectNo
    createNo
    detectLanguageNo
    duplicateNo
    executeScriptNo
    getNo
    getAllInWindowNo
    getCurrentNo
    getSelectedNo
    getZoomNo
    getZoomSettingsNo
    highlightNo
    insertCSSNo
    moveNo
    onActivatedNo
    onActiveChangedNo
    onAttachedNo
    onCreatedNo
    onDetachedNo
    onHighlightChangedNo
    onHighlightedNo
    onMovedNo
    onRemovedNo
    onReplacedNo
    onSelectionChangedNo
    onUpdatedNo
    onZoomChangeNo
    queryNo
    reloadNo
    removeNo
    sendMessageNo
    sendRequestNo
    setZoomNo
    setZoomSettingsNo
    updateNo

    1. The 'selected' option is deprecated and not supported in Firefox. Use 'active' instead.
    2. It's not possible to update the "highlighted" and "selected" properties.

    The "Chrome incompatibilities" section is included from https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities using the WebExtChromeCompat macro.

    If you need to update this content, edit https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities, then shift-refresh this page to see your changes.

    Chrome incompatibilities

    • Firefox does not support:
      • sendRequest()
      • getSelected()
      • onActiveChanged
      • onHighlightChanged
      • onSelectionChanged
    • Additionally:
      • Firefox treats highlighted and active as the same, since Firefox has no concept of selecting multiple tabs.
      • In Firefox, you need the tabs permission if you want to include url in the queryInfo parameter to tabs.query().
      • In Firefox, relative URLs passed into tabs.executeScript() or tabs.insertCSS() are resolved relative to the current page URL. In Chrome, these URLs are resolved relative to the add-on's base URL. To work cross-browser, you can specify the path as an absolute URL, starting at the add-on's root, like this:

        /path/to/script.js
      • In Firefox, you can't open (using tabs.create), or navigate to (using tabs.update) privileged URLs:
        • chrome: URLs
        • javascript: URLs
        • data: URLs
        • privileged about: URLs (for example, about:config, about:addons, about:debugging)

    Example add-onsEdit

    • beastify
    • Bookmark it!
    • chill-out
    • inpage-toolbar-ui
    • open-my-page-button
    • tabs-tabs-tabs

    Acknowledgements

    This API is based on Chromium's chrome.tabs API. This documentation is derived from tabs.json in the Chromium code.

    // Copyright 2015 The Chromium Authors. All rights reserved.
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions are
    // met:
    //
    //    * Redistributions of source code must retain the above copyright
    // notice, this list of conditions and the following disclaimer.
    //    * Redistributions in binary form must reproduce the above
    // copyright notice, this list of conditions and the following disclaimer
    // in the documentation and/or other materials provided with the
    // distribution.
    //    * Neither the name of Google Inc. nor the names of its
    // contributors may be used to endorse or promote products derived from
    // this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    Share:
    • Twitter
    • Facebook
    • Google+

    Document Tags and Contributors

    Tags: 
    • add-ons
    • Add-ons
    • API
    • Extensions
    • Interface
    • Non-standard
    • Reference
    • tabs
    • WebExtensions
     Contributors to this page: wbamberg, kmaglione
     Last updated by: wbamberg, Apr 15, 2016, 11:49:08 AM
    See also
    1. WebExtensions
    2. Getting started
      1. Prerequisites
      2. Anatomy of a WebExtension
      3. Packaging and Installation
      4. Walkthrough
      5. Examples
    3. Guides
      1. Content scripts
      2. Porting from Google Chrome
      3. Match patterns
      4. Debugging
      5. Chrome incompatibilities
    4. JavaScript APIs
      1. alarms
      2. bookmarks
      3. browserAction
      4. commands
      5. contextMenus
      6. cookies
      7. downloads
      8. events
      9. extension
      10. extensionTypes
      11. i18n
      12. idle
      13. notifications
      14. pageAction
      15. runtime
      16. storage
      17. tabs
        1. Methods
          1. captureVisibleTab()
          2. connect()
          3. create()
          4. detectLanguage()
          5. duplicate()
          6. executeScript()
          7. get()
          8. getAllInWindow()
          9. getCurrent()
          10. getSelected()
          11. getZoom()
          12. getZoomSettings()
          13. highlight()
          14. insertCSS()
          15. move()
          16. query()
          17. reload()
          18. remove()
          19. sendMessage()
          20. sendRequest()
          21. setZoom()
          22. setZoomSettings()
          23. update()
        2. Properties
          1. TAB_ID_NONE
        3. Types
          1. MutedInfo
          2. MutedInfoReason
          3. Tab
          4. TabStatus
          5. WindowType
          6. ZoomSettings
          7. ZoomSettingsMode
          8. ZoomSettingsScope
        4. Events
          1. onActivated
          2. onActiveChanged
          3. onAttached
          4. onCreated
          5. onDetached
          6. onHighlightChanged
          7. onHighlighted
          8. onMoved
          9. onRemoved
          10. onReplaced
          11. onSelectionChanged
          12. onUpdated
          13. onZoomChange
      18. webNavigation
      19. webRequest
      20. windows
    5. Manifest keys
      1. applications
      2. background
      3. browser_action
      4. content_scripts
      5. default_locale
      6. description
      7. icons
      8. manifest_version
      9. name
      10. options_ui
      11. page action
      12. permissions
      13. version
      14. web_accessible_resources
    6. Add-on SDK
    7. Getting started
      1. Installation
      2. Getting started
      3. Troubleshooting
    8. High-Level APIs
      1. addon-page
      2. base64
      3. clipboard
      4. context-menu
      5. hotkeys
      6. indexed-db
      7. l10n
      8. notifications
      9. page-mod
      10. page-worker
      11. panel
      12. passwords
      13. private-browsing
      14. querystring
      15. request
      16. selection
      17. self
      18. simple-prefs
      19. simple-storage
      20. system
      21. tabs
      22. timers
      23. ui
      24. url
      25. widget
      26. windows
    9. Low-Level APIs
      1. /loader
      2. chrome
      3. console/plain-text
      4. console/traceback
      5. content/content
      6. content/loader
      7. content/mod
      8. content/symbiont
      9. content/worker
      10. core/heritage
      11. core/namespace
      12. core/promise
      13. dev/panel
      14. event/core
      15. event/target
      16. frame/hidden-frame
      17. frame/utils
      18. fs/path
      19. io/byte-streams
      20. io/file
      21. io/text-streams
      22. lang/functional
      23. lang/type
      24. loader/cuddlefish
      25. loader/sandbox
      26. net/url
      27. net/xhr
      28. places/bookmarks
      29. places/favicon
      30. places/history
      31. platform/xpcom
      32. preferences/event-target
      33. preferences/service
      34. remote/child
      35. remote/parent
      36. stylesheet/style
      37. stylesheet/utils
      38. system/child_process
      39. system/environment
      40. system/events
      41. system/runtime
      42. system/unload
      43. system/xul-app
      44. tabs/utils
      45. test/assert
      46. test/harness
      47. test/httpd
      48. test/runner
      49. test/utils
      50. ui/button/action
      51. ui/button/toggle
      52. ui/frame
      53. ui/id
      54. ui/sidebar
      55. ui/toolbar
      56. util/array
      57. util/collection
      58. util/deprecate
      59. util/list
      60. util/match-pattern
      61. util/object
      62. util/uuid
      63. window/utils
    10. Firefox for Android
    11. Getting started
      1. Walkthrough
      2. Debugging
      3. Code snippets
    12. APIs
      1. Accounts.jsm
      2. BrowserApp
      3. HelperApps.jsm
      4. Home.jsm
      5. HomeProvider.jsm
      6. JavaAddonManager.jsm
      7. NativeWindow
      8. Notifications.jsm
      9. PageActions.jsm
      10. Prompt.jsm
      11. RuntimePermissions.jsm
      12. Snackbars.jsm
      13. Sound.jsm
      14. Tab
    13. Legacy
    14. Restartless extensions
      1. Overview
    15. Overlay extensions
      1. Overview
    16. Themes
    17. Lightweight themes
      1. Overview
    18. Complete themes
      1. Overview
    19. Publishing add-ons
    20. Guides
      1. Signing and distribution overview
      2. Submit an add-on
      3. Review policies
      4. Developer agreement
      5. Featured add-ons
      6. Contact addons.mozilla.org
    21. Community and support
    22. Channels
      1. Add-ons blog
      2. Add-on forums
      3. Stack Overflow
      4. Development newsgroup
      5. IRC Channel

    © 2005-2016 Mozilla Developer Network and individual contributors.

    Content is available under these licenses.

    • About MDN
    • Terms
    • Privacy
    • Cookies
    • Contribute to the code

    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy
    BESbswy