タブを開く

var aTab = gBrowser.loadOneTab(url, {inBackground:false}); 

タブのブラウザオブジェクト (xul:browser) を取得

aTab.linkedBrowser;
gBrowser.getBrowserForTab(aTab); //中身は↑
基本。

タブのURLを取得

特定のタブ

aTab.linkedBrowser.currentURI.spec;
currentURI は nsIURI

カレントタブ

window.content.location.href;
window.content.document.URL;  ←タブにXULを読み込んでたりするとundefinedになる
gBrowser.currentURI.spec;
gBrowser.mCurrentBrowser.currentURI.spec;
mCurrentTab.linkedBrowser.currentURI.spec;
カレントタブに限定するとバリエーションが一気に広がる

タブのindexを取得

注意:もうちょっと調べてみるべき

特定のタブ

var index = tab._tPos;
あるいは、
var index;
var list = gBrowser.visibleTabs;
if (list.length > 1) {
    index = list.indexOf(tab);
} else {
    index = 0;
} 

カレントタブ

var index = gBrowser.tabContainer.selectedIndex;

特定のタブをアクティブにする

gBrowser.selectedTab = aTab;

コンテントエリアのchromeスクリプトが、それを表示してるタブを取得

var Ci = Components.interfaces;
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
	.getInterface(Ci.nsIWebNavigation)
	.QueryInterface(Ci.nsIDocShellTreeItem)
	.rootTreeItem
	.QueryInterface(Ci.nsIInterfaceRequestor)
	.getInterface(Ci.nsIDOMWindow);
var selfTab = mainWindow.gBrowser._getTabForContentWindow(window);

タブがピン留めされてるかどうか

aTab.pinned; //true or false

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2014年10月30日 08:46