Movatterモバイル変換


[0]ホーム

URL:


  1. Mozilla
  2. Add-ons
  3. Browser extensions
  4. JavaScript APIs
  5. tabGroups
  6. tabGroups.onMoved

tabGroups.onMoved

Fires when a tab group is moved within a window or to another window.tabs.onMoved also fire for the tabs within the group.

The event is passed atabGroups.TabGroup object. This includes thewindowId but not the position of the tab group. To determine the position of the tab group, usetabs.query() with thegroupId, and read theindex property of the returned tab.

In Chrome, this event doesn't fire when a tab group is moved between windows; instead, the group is removed from one window and created in another (firingtabGroups.onRemoved andtabGroups.onCreated.

Syntax

js
browser.tabGroups.onMoved.addListener(listener)browser.tabGroups.onMoved.removeListener(listener)browser.tabGroups.onMoved.hasListener(listener)

Events have three functions:

addListener(listener)

Adds a listener to this event.

removeListener(listener)

Stops listening to this event. Thelistener argument is the listener to remove.

hasListener(listener)

Checks whetherlistener is registered for this event. Returnstrue if it is listening,false otherwise.

addListener syntax

Parameters

listener

The function called when this event occurs. The function is passed this argument:

group

tabGroups.TabGroup. Details of the moved tab group's state.

Examples

Listen for and log tab group movement:

js
function tabGroupMoved(group) {  console.log(    `Tab group with ID ${group.id} was moved to window ${group.windowId}.`,  );}browser.tabGroups.onMoved.addListener(tabGroupMoved);

Locate a tab group moved to another window.

js
browser.tabGroups.onMoved.addListener(group => {  let tabs = await browser.tabs.query({    groupId: group.id,  });  console.log(`Moved tab group to ${tabs[0].index} in window ${group.windowId}`);});

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp