Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 509041 of tabs/utils

  • Revision slug: Mozilla/Add-ons/SDK/Low-Level_APIs/tabs_utils
  • Revision title: tabs/utils
  • Revision id: 509041
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment

Revision Content

Unstable

Functions for working with XUL tabs and the XUL tabbrowser object.

Globals

Functions

activateTab(tab, window)

Set the specified tab as the active, or selected, tab.

Parameters

tab : tab
A XUL tab element to activate.

window : window
A browser window.

getTabBrowser(window)

Get the tabbrowser element for the given browser window.

Parameters

window : window
A browser window.

Returns

tabbrowser :

getTabContainer(window)

Get the tabbrowser's tabContainer property.

Parameters

window : window
A browser window.

Returns

tabContainer :

getTabs(window)

Returns the tabs for the specified window.

If you omit window, this function will return tabs across all the browser's windows. However, if your add-on has not opted into private browsing, then the function will exclude all tabs that are hosted by private browser windows.

To learn more about private windows, how to opt into private browsing, and how to support private browsing, refer to the documentation for the private-browsing module.

Parameters

window : nsIWindow
Optional.

Returns

Array : An array of tab elements.

getActiveTab(window)

Given a browser window, get the active, or selected, tab.

Parameters

window : window
A browser window.

Returns

tab : The currently selected tab.

getOwnerWindow(tab)

Get the browser window that owns the specified tab.

Parameters

tab : tab
A browser tab.

Returns

window : A browser window.

openTab(window, url, options)

Open a new tab in the specified browser window.

Parameters

window : window
The browser window in which to open the tab.

url : String
URL for the document to load.

options : object
Optional options:

Name Type  
inBackground boolean

If true, open the new tab, but keep the currently selected tab selected. If false, make the new tab the selected tab. Optional, defaults to false.

pinned boolean

Pin this tab. Optional, defaults to false.

Returns

tab : The new tab.

isTabOpen(tab)

Test whether the specified tab is open.

Parameters

tab : tab
A XUL tab element.

Returns

boolean : true if the tab is open, otherwise false.

closeTab(tab)

Close the specified tab.

Parameters

tab : tab
A XUL tab element.

getURI(tab)

Get the specified tab's URI.

Parameters

tab : tab
A XUL tab element.

Returns

String : The current URI.

getTabBrowserForTab(tab)

Get the specified tab's tabbrowser.

Parameters

tab : tab
A XUL tab element.

Returns

tabbrowser :

getBrowserForTab(tab)

Get the specified tab's browser.

Parameters

tab : tab
A XUL tab element.

Returns

browser :

getTabTitle(tab)

Get the title of the document hosted by the specified tab, or the tab's label if the tab doesn't host a document.

Parameters

tab : tab
A XUL tab element.

Returns

String :

setTabTitle(tab, title)

Set the title of the document hosted by the specified tab, or the tab's label if the tab doesn't host a document.

Parameters

tab : tab
A XUL tab element.

title : String
The new title.

getTabContentWindow(tab)

Get the specified tab's content window.

Parameters

tab : tab
A XUL tab element.

Returns

window :

getAllTabContentWindows()

Get all tabs' content windows across all the browsers' windows.

Returns

Array : Array of windows.

getTabForContentWindow(window)

Get the tab element that hosts the specified content window.

Parameters

window : window

Returns

tab :

getTabURL(tab)

Get the specified tab's URL.

Parameters

tab : tab
A XUL tab element.

Returns

String : The current URI.

setTabURL(tab, url)

Set the specified tab's URL.

Parameters

tab : tab
A XUL tab element.

url : String

getTabContentType(tab)

Get the contentType of the document hosted by the specified tab.

Parameters

tab : tab
A XUL tab element.

Returns

String :

getSelectedTab(window)

Get the selected tab for the specified browser window.

Parameters

window : window

Returns

tab : A XUL tab element.

Revision Source

<div class="note">
 <p>Unstable</p>
</div>
<p><span class="seoSummary">Functions for working with XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tabs</code></a> and the XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser"><code>tabbrowser</code></a> object.</span></p>
<h2>Globals</h2>
<h3>Functions</h3>
<h4 class="addon-sdk-api-name"><code>activateTab(tab, window)</code></h4>
<p>Set the specified tab as the active, or <a href="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser#p-selectedTab">selected</a>, tab.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A <a href="https://developer.mozilla.org/en-US/docs/XUL/tab">XUL <code>tab</code> element</a> to activate.</p>
<p><strong>window : window</strong><br />
 A browser window.</p>
<h4 class="addon-sdk-api-name"><code>getTabBrowser(window)</code></h4>
<p>Get the <a href="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser"><code>tabbrowser</code></a> element for the given browser window.</p>
<h5>Parameters</h5>
<p><strong>window : window</strong><br />
 A browser window.</p>
<h5>Returns</h5>
<p><strong>tabbrowser</strong> :</p>
<h4 class="addon-sdk-api-name"><code>getTabContainer(window)</code></h4>
<p>Get the <code>tabbrowser</code>'s <a href="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser#p-tabContainer"><code>tabContainer</code></a> property.</p>
<h5>Parameters</h5>
<p><strong>window : window</strong><br />
 A browser window.</p>
<h5>Returns</h5>
<p><strong>tabContainer</strong> :</p>
<h4 class="addon-sdk-api-name"><code>getTabs(window)</code></h4>
<p>Returns the tabs for the specified <code>window</code>.</p>
<p>If you omit <code>window</code>, this function will return tabs across all the browser's windows. However, if your add-on has not opted into private browsing, then the function will exclude all tabs that are hosted by private browser windows.</p>
<p>To learn more about private windows, how to opt into private browsing, and how to support private browsing, refer to the <a href="modules/sdk/private-browsing.html">documentation for the <code>private-browsing</code> module</a>.</p>
<h5>Parameters</h5>
<p><strong>window : nsIWindow</strong><br />
 Optional.</p>
<h5>Returns</h5>
<p><strong>Array</strong> : An array of <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> elements.</p>
<h4 class="addon-sdk-api-name"><code>getActiveTab(window)</code></h4>
<p>Given a browser window, get the active, or <a href="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser#p-selectedTab">selected</a>, tab.</p>
<h5>Parameters</h5>
<p><strong>window : window</strong><br />
 A browser window.</p>
<h5>Returns</h5>
<p><strong>tab</strong> : The currently selected <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a>.</p>
<h4 class="addon-sdk-api-name"><code>getOwnerWindow(tab)</code></h4>
<p>Get the browser window that owns the specified <code>tab</code>.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A browser <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a>.</p>
<h5>Returns</h5>
<p><strong>window</strong> : A browser window.</p>
<h4 class="addon-sdk-api-name"><code>openTab(window, url, options)</code></h4>
<p>Open a new tab in the specified browser window.</p>
<h5>Parameters</h5>
<p><strong>window : window</strong><br />
 The browser window in which to open the tab.</p>
<p><strong>url : String</strong><br />
 URL for the document to load.</p>
<p><strong>options : object</strong><br />
 Optional options:</p>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Name</th>
   <th scope="col">Type</th>
   <th scope="col">&nbsp;</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>inBackground</td>
   <td>boolean</td>
   <td>
    <p>If <code>true</code>, open the new tab, but keep the currently selected tab selected. If <code>false</code>, make the new tab the selected tab. Optional, defaults to <code>false</code>.</p>
   </td>
  </tr>
  <tr>
   <td>pinned</td>
   <td>boolean</td>
   <td>
    <p>Pin this tab. Optional, defaults to <code>false</code>.</p>
   </td>
  </tr>
 </tbody>
</table>
<h5>Returns</h5>
<p><strong>tab</strong> : The new <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a>.</p>
<h4 class="addon-sdk-api-name"><code>isTabOpen(tab)</code></h4>
<p>Test whether the specified tab is open.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>boolean</strong> : <code>true</code> if the tab is open, otherwise <code>false</code>.</p>
<h4 class="addon-sdk-api-name"><code>closeTab(tab)</code></h4>
<p>Close the specified tab.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h4 class="addon-sdk-api-name"><code>getURI(tab)</code></h4>
<p>Get the specified tab's URI.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>String</strong> : The current URI.</p>
<h4 class="addon-sdk-api-name"><code>getTabBrowserForTab(tab)</code></h4>
<p>Get the specified tab's <a href="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser"><code>tabbrowser</code></a>.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>tabbrowser</strong> :</p>
<h4 class="addon-sdk-api-name"><code>getBrowserForTab(tab)</code></h4>
<p>Get the specified tab's <a href="https://developer.mozilla.org/en-US/docs/XUL/browser"><code>browser</code></a>.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>browser</strong> :</p>
<h4 class="addon-sdk-api-name"><code>getTabTitle(tab)</code></h4>
<p>Get the title of the document hosted by the specified tab, or the tab's label if the tab doesn't host a document.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>String</strong> :</p>
<h4 class="addon-sdk-api-name"><code>setTabTitle(tab, title)</code></h4>
<p>Set the title of the document hosted by the specified tab, or the tab's label if the tab doesn't host a document.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<p><strong>title : String</strong><br />
 The new title.</p>
<h4 class="addon-sdk-api-name"><code>getTabContentWindow(tab)</code></h4>
<p>Get the specified tab's content window.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>window</strong> :</p>
<h4 class="addon-sdk-api-name"><code>getAllTabContentWindows()</code></h4>
<p>Get all tabs' content windows across all the browsers' windows.</p>
<h5>Returns</h5>
<p><strong>Array</strong> : Array of windows.</p>
<h4 class="addon-sdk-api-name"><code>getTabForContentWindow(window)</code></h4>
<p>Get the tab element that hosts the specified content window.</p>
<h5>Parameters</h5>
<p><strong>window : window</strong></p>
<h5>Returns</h5>
<p><strong>tab</strong> :</p>
<h4 class="addon-sdk-api-name"><code>getTabURL(tab)</code></h4>
<p>Get the specified tab's URL.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>String</strong> : The current URI.</p>
<h4 class="addon-sdk-api-name"><code>setTabURL(tab, url)</code></h4>
<p>Set the specified tab's URL.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<p><strong>url : String</strong></p>
<h4 class="addon-sdk-api-name"><code>getTabContentType(tab)</code></h4>
<p>Get the <a href="https://developer.mozilla.org/en-US/docs/DOM/document.contentType"><code>contentType</code></a> of the document hosted by the specified tab.</p>
<h5>Parameters</h5>
<p><strong>tab : tab</strong><br />
 A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
<h5>Returns</h5>
<p><strong>String</strong> :</p>
<h4 class="addon-sdk-api-name"><code>getSelectedTab(window)</code></h4>
<p>Get the selected tab for the specified browser window.</p>
<h5>Parameters</h5>
<p><strong>window : window</strong></p>
<h5>Returns</h5>
<p><strong>tab</strong> : A XUL <a href="https://developer.mozilla.org/en-US/docs/XUL/tab"><code>tab</code></a> element.</p>
Revert to this revision