Search code examples
javascriptgoogle-chrome-extensiontabswindow

chrome api - move tab out of window


Is it possible to take an existing tab, move it out of its window and create a new window directly?

Using the window api I can create a new window with an empty tab, and with the tab api I can move my tab of interest there and remove the empty tab. That's quite a lot of steps and the visual is very different from the manual action of dragging a tab out of its window.

Is there not a way to create a window directly from an existing tab with the api?


Solution

  • There is no possibility to do it in one way, just as you said. First, you need to create a new empty window and then you can use chrome.tabs.move method for it.

    It has one limitation: tabs can only be moved to and from normal (window.type === "normal") windows.

    Example:

    chrome.tabs.move(tabId, { index : 1, windowId: 2 });