Obsolete since Gecko 1.9.2 (Firefox 3.6 / Thunderbird 3.1 / Fennec 1.0)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Handling onclosetab Event

Assuming the tabbox, tabs, and tabpanels widgets with id's the same as their nodeName, this function will correctly remove the current tab and tab panel for the onclosetab tabs event:

function removeTab(){
    var tabbox = document.getElementById("tabbox");
    var currentIndex = tabbox.selectedIndex;
    var tabs=document.getElementById("tabs");
    var tabpanels=document.getElementById("tabpanels");
    /*Work around If last tab is removed, widget fails to advance to next tab*/
    if(-1 == tabbox.selectedIndex && tabs.childNodes.length>0){

Creating a close tab button

To have a tab close button, you must configure the style.


   .tabs-closebutton {
     list-style-image: url(;
   .tabs-closebutton {
     list-style-image: url("chrome://global/skin/icons/Close.gif");