Here is a list of some extra methods and properties provided by Tabbrowser Extensions for tab
and tabbrowser
widget. You can use these properties by your original XUL applications and they will power your apps. Or, if you use customizable extensions about mouse gesures, buttons, etc., you can call TBE features with following methods.
Name | Type | Description |
---|---|---|
tab widget | ||
tabId | String (readonly) | is the identifier string for the tab. If you use direct reference for the element node of the tab, memory leak sometimes appears. I recommend you to use this ID to identify tabs from events or other cases. (You can identify the tab from this ID by the method getTabByTabId() of the tabbrowser widget.) |
childTabs | Array of Element Nodes (readonly) | This are child tabs related to the tab directly. The length of this array will be "0", if the TabGroup Mode is disabled or the tab has no child. You can edit this by methods of tabbrowser widget, attachTabTo() and detachTab() . |
hasChildTabs() | method | returns a boolean value which indicates the tab has child tabs or not. This is quicker than accessing the childTabs property. |
allChildTabs | Array of Element Nodes (readonly) | is a simple array that includes all of children related to the tab directly or indirectly. The length of this array will be "0", if the TabGroup Mode is disabled or the tab has no child. |
parentTab | Element Node | is the parent tab related to the tab directly. It will be null , if the TabGroup Mode is disabled or the tab has no parent. You can edit this by methods of tabbrowser widget, attachTabTo() and detachTab() . |
rootTab | Element Node (readonly) | is the top-level parent of the tab. It will be null , if the TabGroup Mode is disabled or the tab has no parent. |
ownerGroup | Array of Element Nodes (readonly) | is a simple array that has all of tabs of the group which contains the tab. The length of this array will be "0", if the TabGroup Mode is disabled or the tab is not grouped. |
previousTab | Element Node (readonly) | is the previous tab of the tab. This always refers the previously displayed even if users rearrangeed tabs. |
nextTab | Element Node (readonly) | is the next tab of the tab. This always refers the next displayed even if users rearrangeed tabs. |
locked | Boolean | is a property which indicates the tab is locked or unlocked. |
referrerBlocked | Boolean | is a property which indicates the tab is blocked or unblocked sending HTTP_REFERER. |
autoReloadInterval | Number | is the inverval of auto-reloading (msec). A 0 stops reloading of the tab. |
allowPlugins | Boolean | allows/forbids to use plug-ins in the tab. |
allowJavascript | Boolean | allows/forbids to use JavaScript in the tab. |
allowMetaRedirects | Boolean | allows/forbids to use redirecting or reloading by webpages in the tab. |
allowSubframes | Boolean | allows/forbids to show frames in the tab. |
allowImages | Boolean | allows/forbids to load imagesin the tab. |
fixedLabel | String | sets the fixed label of the tab. To cancel fixed labels, you should set null . |
tabbrowser widget | ||
getTabByTabId(aID) | method | finds and returns a tab from tabId . If there is no tab which has the ID, this returns null . Tabs' ID will be used instead of direct references to element nodes of tabs. |
tabGroupsAvailable | Boolean (readonly) | indicates the TabGroup Mode is enabled or disabled. |
attachTabTo(aTab, aParent) | method | relates the tab aTab to the parent tab aParent as a child. The expression attachTabTo(aTab, aParent) is equals to aTab.parentTab = aParent . |
detachTab(aTab, aKeepChildTabs) | method | releases aTab from the parent. For example, when there is a group of three tabs, A(root), B(child of A) and C(child of B), detachTab(B, true) releases the small group B and C, detachTab(B, false) releases only B. And, the expression detachTab(aTab, true) is equals to aTab.parentTab = null . |
removeAllTabs() | method | closes any tab. This returns no value. |
removeLeftTabsFrom(aTab), removeRightTabsFrom(aTab) | method | closes all of tabs located in left/right of the tab. This returns the handed tab. |
undoRemoveTab() | method | reopens the tab last closed, and returns it. |
moveTabTo(aTab, aIndex) | method | moves the tab to the absolute position. For example, when you hand "0", the tab will be moved to the left edge. If the position is out of range, the tab will be moved to left or right edge. This returns the moved tab. |
moveTabBy(aTab, aOrder) | method | moves the tab by the relative order. For example, when you hand "-2", the tab will be moved to the left twice. If the position is out of range, the tab will be moved to left or right edge. This returns the moved tab. |
moveTabLeft(aTab), moveTabRight(aTab) | method | moves the tab to the left or right. If you move the tab of the left edge to the left it will be moved to the right edge. |
removeTabGroup(aTab) | method | closes the tab and child tabs (but the parent and brothers are not). When the TabGroup Mode is disabled, this works like removeTab() . This returns no value. |
editBookmarkFromTab(aTab) | method | opens a bookmark property dialog for the bookmarked page. This will do no action if the page is not bookmarked. This returns the handed tab. |
duplicateTab(aTab) | method | copies the tab, in the same window. This returns the new (duplicated) tab. |
duplicateTabInWindow(aTab) | method | opens a new window for the copied tab. This returns the original tab. |
sortTabsByGroup() | method | sorts all of tabs by groups. This will do no action when the TabGroup Mode is disabled. |
setTabColorFor(aTab, aColorSet) | method | sets background and font color of the tab. This will change child tabs of the tab too, if the TabGroup Mode is available. You should hand a string aColorSet like following:
|
getTabInfo(aTab) | method | gets an information object ([object XULTabbrowserTabInfo]) of the tab. It contains label, session histories, and so on. |
addTabWithTabInfo(aTabInfo) | method | opens a tab which has same label, histories, etc. This method needs a tab information created by the method getTabInfo() . This returns the new tab. |
You can use different implementation for with-tabextensions or without, like following:
// ex. A feature to download set of tabs
// with tabextensions : Download current tab-group
// without tabextensions : Download all tabs
var tabs = ('TabbrowserService' in window) ? gBrowser.selectedTab.ownerGroup : [] ;
if (!tabs.length) tabs = gBrowser.mTabContainer.childNodes;
for (var i = 0; i < tabs.length; i++) {
saveDocument(gBrowser.getBrowserForTab(tabs[i]).contentDocument);
}
And, you can call those methods from mouse gestures provided by other extensions, like:
gBrowser.undoRemoveTab();
"tabbrowser" elements dispatch following special events if TBE is installed. You can use them to use your custom features about the tabbed browsing.
Name | When the event is dispatched? | Extra properties |
---|---|---|
XULTabbrowserTabAdded | When a new tab is opened. |
|
XULTabbrowserAddTabCanceled | When new tab isn't opened because there are too many tabs. |
|
XULTabbrowserTabRemoved | When a tab is closed. |
|
XULTabbrowserTabLoading | While a tab is loading. |
|
XULTabbrowserTabLoad | When a tab is completely loaded. |
|
XULTabbrowserTabLocationChange | When the location of the page currently shown in the tab is changed. |
|
XULTabbrowserUndoCacheAdded | When a closed tab is cached. |
|
XULTabbrowserUndoCacheOverFlowed | When the cache is filled up and the oldest entry is automatically removed. |
|
XULTabbrowserUndoCacheRemoved | When an entry is removed from the cache. |
|
XULTabbrowserTabStatusChange | When status of tabs (locked, forbid to load images, or others) is changed. |
|
XULTabbrowserTabMoved | When a tab is moved (rearranged). |
|
XULTabbrowserURIDrop | When an URI string is dropped on the tab bar. |
|
XULTabbrowserTabDrop | When a tab is dropped on the tab bar. |
|
TabbrowserTabGroupModified | When a group of tabs is modified. |
|
You can use those events for your implementation like:
// ex. A feature to close new tabs automatically if I open them for movies.
function onTabLoad(aEvent) {
if (aEvent.tabURI.match(/\.(rm|ram|avi|mov|wmv|asf)$/i)) {
var tabbrowser = aEvent.target;
var tab = tabbrowser.getTabByTabId(aEvent.tabId);
tabbrowser.removeTab(tab);
}
}
window.addEventListener('XULTabbrowserTabLoad', onTabLoad, true);