虽然看起来您可以通过更新选项卡.index属性来更改窗口中选项卡的顺序,但它看起来不像 tabs api直接支持将选项卡移动到另一个窗口. 我错过了什么吗?有可行的解决方法吗? 可以通过低
我错过了什么吗?有可行的解决方法吗?
可以通过低级模块窗口/工具来实现.下面的示例在每个打开的窗口中复制活动选项卡const { getMostRecentBrowserWindow, windows: getWindows } = require("sdk/window/utils"); const { ActionButton } = require("sdk/ui/button/action"); var button = ActionButton({ id: "duplicatetab-button", label: "Duplicate tab", icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACUElEQVQ4jaWTTWtTURCGjzc33CCpbVKN4kexC9EUY1Hov+iqPyDrbgtuCrViKUERqsWVguBGQaW4UiKiaEVxoShFGgnuBMUqNW3zce49Z+ZxUWtwoRR8YXbzPswM7xj+JgVEiXGsYVknxgII4Ltt5p8AB8RArOAUVQfqQJNtAFA8QgvF6i9PR1Dt0KbVBTjncM4hIni/OZv3HsRB+wvefiP2LcQnJIkQe49FEJFNQLPZZHh4mEwmQyqVoqenh3K5TGvlK1dOlageH+HG4DFar1/S0A6Lr99xdN8QxWKRXC6HGR0dJZvNMjk5Sb1ep1gskk6nuTo/D+/ec7dvkBdhP9cKeX7UXxEZQ2/YRxRFLC8vY+bm5qhUKnjvsdYyPj5OFEWcnTnHujiS5TfcPDbAw50h9w7u5f7UadLZFLVaDRHBiGzuY61lbGyMXC5HoVBgrbGGWAW/TvvxHR7s7udFKs/1oyfZ+PSRTqeDqm7eoFqtEoYhmUyG2dlZVJU4iREfI/WP3Nt9iMUdu7jdf5Anly5i0oaVlRWazSZmYWGBIAiIoohyucz09DQTExPMnJli9dlT5vcM8Kh3gFsHDuNqb9mb7yXMRBhjWFpawpRKJVKpFMYYgiAgDEOCIOD81BkunBjh8pEhKqUhGkvP6bQ/U//wgUP5/YRhSDabxbTbbVQV5xyq2q0kgR8NdOM7JKuo/Y5qggqIdPvMlnkrQCKCquJFsOrxeHAJxA48eFU6Xv4EqOpv41YqnQirqliv4MEmQtN7RBSs7wL+/gvb038DfgJnyUabbHzUbQAAAABJRU5ErkJggg==", onClick: function() { var xulwindows = getWindows("navigator:browser"); var xulactivewindow = getMostRecentBrowserWindow(); var xulactivetab = xulactivewindow.gBrowser.selectedTab; xulwindows.forEach(function(win){ if(win === xulactivewindow) return; var duplicatedtab = win.gBrowser.duplicateTab(xulactivetab); win.gBrowser.moveTabTo(duplicatedtab, 0); // the second argument is the index }); } });