tabbrowser

This element is used for holding a set of read-only views of Web documents. It is similar to the browser element, except that multiple documents can be displayed, each in a separate tab.

Note: Starting in Firefox 3 (XULRunner/Gecko 1.9), this is only used in the main Firefox window and cannot be used in other XUL windows by third-party applications or extensions.

Attributes
autocompleteenabled, autocompletepopup, autoscroll, contentcontextmenu, contenttooltip, handleCtrlPageUpDown, onbookmarkgroup, onnewtab, tabmodalPromptShowing
Properties
browsers, canGoBack, canGoForward, contentDocument, contentTitle, contentViewerEdit, contentViewerFile, contentWindow, currentURI, docShell, documentCharsetInfo, homePage, markupDocumentViewer, securityUI, selectedBrowser, selectedTab, sessionHistory, tabContainer, tabs, visibleTabs, webBrowserFind, webNavigation, webProgress
Methods
addProgressListener, addTab, addTabsProgressListener,appendGroup, getBrowserAtIndex, getBrowserIndexForDocument, getBrowserForDocument, getBrowserForTab, getIcon, getNotificationBox, getTabForBrowser, getTabModalPromptBox, goBack, goBackGroup, goForward, goForwardGroup, goHome, gotoIndex, loadGroup, loadOneTab, loadTabs, loadURI, loadURIWithFlags, moveTabTo, pinTab, reload, reloadAllTabs, reloadTab, reloadWithFlags, removeAllTabsBut, removeCurrentTab, removeProgressListener, removeTab, removeTabsProgressListener,replaceGroup, selectTabAtIndex, setIcon, showOnlyTheseTabs, stop, unpinTab

Attributes

autocompleteenabled
Type: boolean
Set to true to enable autocomplete of fields.
autocompletepopup
Type: id
The id of a popup element used to hold autocomplete results for the element.
autoscroll
Type: boolean
Set to false to disable autoscroll for this browser. If this attribute is set to true or omitted, autoscroll will be enabled or depending on the user preference general.autoScroll.
contentcontextmenu
Type: id
The id of a menupopup element serving as the context menu for the content area in the tabbrowser.
contenttooltip
Type: id
The id of a tooltip element to be used for the content area in the tabbrowser.
handleCtrlPageUpDown
Type: boolean
If set to true or omitted, the Control and Page Up or Page Down keys can be used to switch to the next or previous tab. If this attribute is set to false, these keys do not navigate between tabs.
onbookmarkgroup
Not in Firefox
Type: script code
This code executes when the user chooses the "Bookmark this Group of Tabs" command.
onnewtab
Not in Firefox
Type: script code
This script will be called when the new tab button is clicked.
tabmodalPromptShowing
Type: integer
The number of tab modal prompts currently attached to the current tab.

Properties

browsers
Type: nodelist of browser elements
Holds a list of the browser elements inside the tabbrowser.
canGoBack
Type: boolean
This read-only property is true if there is a page to go back to in the session history and the Back button should be enabled.
canGoForward
Type: boolean
This read-only property is true if there is a page to go forward to in the session history and the Forward button should be enabled.
contentDocument
Type: document
This read-only property contains the document object in the element.
contentTitle
Type: string
This read-only property contains the title of the document object in the browser.
contentViewerEdit
Type: nsIContentViewerEdit
This read-only property contains the nsIContentViewerEdit which handles clipboard operations on the document.
contentViewerFile
Type: nsIContentViewerFile
Reference to the nsIContentViewerFile interface for the document.
contentWindow
Type: TODO
Use the contentWindow.wrappedJSObject to obtain a DOM(html) window object
currentURI
Type: nsIURI
This read-only property contains the currently loaded URL. To change the URL, use the loadURI method.
docShell
Type: nsIDocShell
This read-only property contains the nsIDocShell object for the document.
documentCharsetInfo Obsolete since Gecko 12.0
Type: nsIDocumentCharsetInfo
This read-only property contains the nsIDocumentCharsetInfo object for the document which is used to handle which character set should be used to display the document. The properties of the nsIDocumentCharsetInfo object were merged into the docshell in Gecko 12.0 (Firefox 12.0 / Thunderbird 12.0 / SeaMonkey 2.9).
homePage
Type: string home page URL
This property holds the value of the user's home page setting.
markupDocumentViewer
Type: nsIMarkupDocumentViewer
This read-only property contains the nsIMarkupDocumentViewer which is responsible for drawing the document.
securityUI
Type: nsISecureBrowserUI
The read-only property holds an object which may be used to determine the security level of the loaded document.
selectedBrowser
Type: browser element
This read-only property returns the currently displayed browser element.
selectedTab
Type: tab element
A reference to the currently selected tab, which will always be one of the tab elements in the tabs element. Assign a value to this property to modify the currently selected tab.
sessionHistory
Type: nsISHistory
This read-only property contains the nsISHistory object which holds the session history.
tabContainer
Type: tabs element
Returns the tabs element that contains the tabs. This is useful for add-ons that need to use events related to tabs in the browser window.
tabs
Type: array
A NodeList containing the tab objects for each tab in the tabbrowser. This is a shortcut for looking at the tabs in the tabContainer.
visibleTabs
Type: array
An array containing tab objects for each visible tab in the tabbrowser. This lets you determine which tabs are visible in the current tab set.
webBrowserFind
Type: nsIWebBrowserFind
This read-only property contains an nsIWebBrowserFind object which can be used to search for text in the document.
webNavigation
Type: nsIWebNavigation
This read-only property contains the nsIWebNavigation object for the document. Most of its methods are callable directly on the element itself, such as goBack and goForward. It also contains the load constants used by reloadWithFlags and loadURIWithFlags.
webProgress
Type: nsIWebProgress
This read-only property contains an nsIWebProgress object which is used to monitor the progress of a document loading.

Methods

Inherited Methods
addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature(), getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

addProgressListener( listener )
Return type: no return value
Add a progress listener to the browser which will monitor loaded documents. The progress listener should implement the nsIWebProgressListener interface.
addTab( URL, referrerURI, charset, postData, owner, allowThirdPartyFixup )
addTab( URL, {referrerURI: ..., charset: ..., postData: ..., owner: ..., allowThirdPartyFixup: ..., relatedToCurrent: ... })
Return type: tab element
Opens a new tab that loads a page with the specified URL. The rest of the parameters are optional. The row of tabs will appear if needed.

Firefox 3.6 note

The second form of this method was added in Firefox 3.6; it allows you to specify the parameters by name, in any order. It also adds the relatedToCurrent parameter; Firefox uses this to decide whether the new tab should be inserted next to the current tab.

See Code snippets:Tabbed browser for examples.
See Preprocessing POST Data for preparing postData out of a string.

 

addTabsProgressListener( listener )
Return type: no return value
Add a progress listener to the browser which will monitor loaded documents in all tabs in the tabbed browser. The progress listener should be based on the nsIWebProgressListener interface with an additional "browser" argument as the first argument of every method, which is the browser (not <tabbrowser> = gBrowser) where the event occurred. See Listening to events on all tabs for details.
appendGroup( group )
Return type: no return value
Not in Firefox
Add several new tabs to the end of the existing tabs. The argument should be an array of objects, one for each document to load. The objects may be defined in script and contain a URI property for the URL of the page to load. A referrerURI property may also be optionally used to set the referrer page.
getBrowserAtIndex( index )
Return type: browser element
Returns a browser at the specified tab index.
getBrowserIndexForDocument( document )
Return type: integer
Returns the index of the browser for the specified document in the tabbrowser the method was invoked on. The returned index is dependent on the tabs in the tabbrowser and is invalidated when the tab ordering changes. It should not be used to track per-tab data during a session; the use of linkedpanel on the corresponding tab is preferred instead.
getBrowserForDocument( document )
Return type: browser element
Returns a browser for the specified document.

 

getBrowserForTab( tab )
Return type: browser element
Returns a browser for the specified tab element.
getIcon( aTab )
Return type: string
Returns the URL of the specified tab's favicon. If aTab is null, the current tab's icon is returned. See setIcon to set the icon.
getNotificationBox( browser )
Return type: notificationbox element
Returns a notificationbox for the specified browser element.
getTabForBrowser( browser ) Requires Gecko 35
Return type: tab
Returns the XUL tab which contains the specified browser.
getTabModalPromptBox( browser )
Return type: object
Returns an object that manages tab-modal prompts for the specified browser. Returns a promptBox object representing the new prompt.
goBack()
Return type: no return value
Go back one page in the history.
goBackGroup()
Not in Firefox
Return type: no return value
Returns to the previous group of tabs.
goForward()
Return type: no return value
Go forward one page in the history.
goForwardGroup()
Not in Firefox
Return type: no return value
Go forward to the next group of tabs.
goHome()
Return type: no return value
Load the user's home page into the browser.
gotoIndex( index )
Return type: no return value
Navigate to the page in the history with the given index. Use a positive number to go forward and a negative number to go back.
loadGroup( group )
Not in Firefox
Return type: the first tab
Loads a group of pages into multiple tabs. They are either appended or replaced depending on the state of the preference browser.tabs.loadGroup. The argument should be an array of objects, one for each document to load. The objects may be defined in script and contain a URI property for the URL of the page to load. A referrerURI property may also be optionally used to set the referrer page. This function returns a reference to the first tab loaded.
loadOneTab( URL, referrerURI, charset, postData, loadInBackground, allowThirdPartyFixup )
loadOneTab( URL, { referrerURI: ..., charset: ..., postData: ..., inBackground: ..., allowThirdPartyFixup: ..., relatedToCurrent: ... })
Return type: tab element
Opens a new tab that loads a page with the specified URL. The rest of the parameters are optional. This method works the same as addTab except for the loadInBackground parameter which allows you to choose whether to open the new tab in foreground or background. There's also no owner parameter as the owner tab is specified automatically.
inBackground
if true the tab will be loaded in the background, if false the tab will be the newly selected tab. And if null or not specified, this parameter will default to the browser.tabs.loadInBackground preference.

Firefox 3.6 note

The second form of this method was added in Firefox 3.6; it adds the relatedToCurrent parameter, and allows the parameters to be specified by name, in any order.

loadTabs( uris, loadInBackground, replace )
loadTabs( uris, params )
Return type: no return value
Loads a set of URIs, specified by the array uris, into tabs. If loadInBackground is true, the tabs are loaded in the background, and if replace is true, the currently displayed tabs are replaced with the specified URIs instead of adding new tabs. The properties of params are following:
  • boolean inBackground
  • boolean replace
  • boolean allowThirdPartyFixup
  • tab targetTab
  • number newIndex
  • object postDatas
  • number userContextId

NOTE: This is the XUL method on <browser> / <tabbrowser>, not the global function in chrome://browser/content/browser.js. Please check which one you're documenting! (This one has no post data parameter, see loadURIWithFlags for a version that does)

loadURI( uri, referrer, charset )
Return type: no return value
Load a URL into the document, with the given referrer and character set.
The first argument should be a string, not a nsIURI object. To get a string from an nsIURI, use nsIURI.spec or nsIURI.asciiSpec
loadURIWithFlags( uri, flags, referrer, charset, postData )
Return type: no return value
Load a URL into the document, with the specified load flags, the given referrer, character set, and POST data. In addition to the flags allowed for the reloadWithFlags method, the following flags are also valid:
  • LOAD_FLAGS_IS_REFRESH: This flag is used when the URL is loaded because of a meta tag refresh or redirect.
  • LOAD_FLAGS_IS_LINK: This flag is used when the URL is loaded because a user clicked on a link. The HTTP Referer header is set accordingly.
  • LOAD_FLAGS_BYPASS_HISTORY: Do not add the URL to the session history.
  • LOAD_FLAGS_REPLACE_HISTORY: Replace the current URL in the session history with a new one. This flag might be used for a redirect.

(See nsIWebNavigation.loadURI() for details on the referrer and postData parameters.)

moveTabTo(tab, index)
Return type: tab element
Tries to moves an existing tab to a given index.
pinTab( tabElement )
Return type: no return value
Pins the specified tab element as an app tab.
reload()
Return type: no return value
Reloads the document in the browser element on which you call this method.
reloadAllTabs()
Return type: no return value
Reloads the contents of all the tabs.
reloadTab( tab )
Return type: no return value
Reloads the contents of a specific tab.
reloadWithFlags( flags )
Return type: no return value
Reloads the document in the browser with the given load flags. The flags listed below may be used, which are all constants of the webNavigation property (or the nsIWebNavigation interface). You may combine flags using a or symbol ( | ).
  • LOAD_FLAGS_NONE: No special flags. The document is loaded normally.
  • LOAD_FLAGS_BYPASS_CACHE: Reload the page, ignoring if it is already in the cache. This is the flag used when the reload button is pressed while the Shift key is held down.
  • LOAD_FLAGS_BYPASS_PROXY: Reload the page, ignoring the proxy server.
  • LOAD_FLAGS_CHARSET_CHANGE: This flag is used if the document needs to be reloaded because the character set changed.
removeAllTabsBut( tabElement )
Return type: no return value
Removes all of the tab panels except for the one corresponding to the specified tab. If only one tab page is displayed, this method does nothing.
removeCurrentTab()
Return type: tab element
Removes the currently displayed tab page. If it is the only displayed tab, this method does nothing.
removeProgressListener( listener )
Return type: no return value
Remove a nsIWebProgressListener from the browser.
removeTab( tabElement )
Return type: no return value
Removes a specific tabbed page corresponding to the given tab element. If only one tab is displayed, this method does nothing (unless the preference browser.tabs.closeWindowWithLastTab is true, in which case the window containing the tab is closed). If browser.tabs.autoHide is true, the row of tabs will collapse if only one tab remains.
removeTabsProgressListener( listener )
Return type: no return value
Removes a progress listener to the browser which has been monitoring all tabs. The progress listener should implement the nsIWebProgressListener interface.
replaceGroup( group )
Not in Firefox
Return type: array of session history objects
Replaces existing tabs with a new set. If there were more tabs before, the additional ones are not removed. You can use the removeTab method to remove the existing tabs first if that is desired. The argument should be an array of objects, one for each document to load. The objects may be defined in script and contain a URI property for the URL of the page to load. A referrerURI property may also be optionally used to set the referrer page. This method returns an array of the session history objects for the tabs that were removed.
selectTabAtIndex( index, event )
Return type: no return value
Selects the tab at the given index. Index values may be positive or negative. If the event argument is supplied, the default event handling will be prevented and propagation stopped.
setIcon( aTab, aURI )
Return type: no return value
Sets the specified tab's favicon to the image specified by aURI. See getIcon to get the current icon.
showOnlyTheseTabs( aTabs )
Return type: no return value
Makes all tabs in the aTabs array visible, and all other tabs hidden.
stop()
Return type: no return value
Equivalent to pressing the Stop button, this method stops the currently loading document.
unpinTab( tabElement )
Return type: no return value
Unpins the specified tab element, making it no longer an app tab.

Document Tags and Contributors

 Contributors to this page: Sheppy, fredy, tawalaya, Natch, Enn, Mgjbot, Nickolay, Vshih, MarkFinkle, Jmort253, Ancestor, Ptak82, Dria
 Last updated by: Sheppy,