The idea of a Tabs control is nothing new. Implemented in form of "Server-side Includes" (SSI) you can find them on many web sites.
Yet, what's new about the Tabs control as presented here is that here you have what could be called "Client-side Includes": Javascript functions for generating the HTML objects making up the tabs row and for implementing the handler function. These functions are downloaded to your readers' computer at begin of session. Once downloaded, they are available immediately, even if the readers go offline afterwards.
That makes a significant difference:SSI-Tabs are available only while the readers are connected to the server. Each time a tab is clicked (i.e. another Contents is to be displayed), that other Contents must be downloaded again. So, a reader soon becomes hesitant to click another tab, incurring another delay for loading the information associated with it. Thus the readers rather tend to miss out on some information, simply for not risking another delay.
True, there is also some load time involved with a CSI-Tab control. However, there is an easy way to hide a good part of it (see
<SCRIPT>Tabs(tab1
</SCRIPT>
<DIV CLASS="Cont" STYLE="display:none">
:
(contents associated with tab1 )
:
</DIV>
:
(as many Cont's as tab's)
:
<DIV CLASS="Cont" STYLE="display:none">
:
(contents associated with last tab )
:
</DIV>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
The number of tabs should be the same as the number of contents you plan to bundle in that Tabs control. Then all contents will be associated with the corresponding tab: the first "Cont" with the first tab, the second "Cont" with the second tab, etc. - up to the last "Cont".
Should their number be different - when a tab is selected that is not associated with a "Cont", a warning sound can be heard.
Each "Cont" can hold any HTML code you like - including another Tabs control (nested Tabs).
When the user clicks a tab, the associated contents are displayed, the contents displayed formerly are hidden.
or
| tab1[|tab2 ] |
Series of strings or string variables. If more than one tab, they should be separated by a comma (,). Any number of tabs can be provided for. Each tab can be plain text or any HTML code you like. If there are more tabs than can be arranged horizontally, the tab row is wrapped to a row beneath. A Tabs control can handle contents of any size. Though it will make sense if you breakdown all of your information such that each part can be accommodated in a 1-screen-contents. If necessary, you can use other layout elements of Online Communication as well (e.g. Dynamic Lists) |
| options | String with any number of options, separated by at least one whitespace. All options are of the form keyword=value . If the value is to hold a whitespace, it needs to be enclosed in quotes: keyword='value' or keyword="value" If the opening quote is a single quote ('), the following single quote is taken to be the closing quote. The same holds true for double quotes ("). In the default calling (upper coding scheme) the tabs are arranged in a horizontal-top-left row. See Arrangement Options what other arrangements are available. Apart from arrangement some other details can be modified as well. |
Currently the following options are available for a Tabs control:
| vertical right bottom | By default, the tabs are arranged as a horizontal row at the top-left corner of the contents. (An example of that you can see here.) However, if any of these keywords is found within the option string, the tabs are arranged vertically, at the right and/or at the bottom of the contents, respectively. These keywords may occur at any place, in any order, within the option string. |
| titles= |
By this option you can give a more comprehensive description to each of your tabs than just 1 word or so. The "
" following titles= is the name of an array holding the descriptions of your arrays. You can create it within the <SCRIPT> … </SCRIPT> bracket before calling function Tabs() , in the following way:
<SCRIPT> var tabtitles = new Array ( "(brief description of tab 1)", "(brief description of tab 2)", : "(brief description of last tab)" ); options="titles='tabtitles'"; Tabs ( ); </SCRIPT> |
| tabwidth= | By default, the browser dimensions each tab such that its label can be fully accommodated, considering its HTML tags, if any. So, normally the tabs will have different widths. This might be hardly noticeable if the arrangement is horizontal. However, with vertical arrangement you will want all tabs to have exactly the same width. You can set it by this option. ( is the number of pixels, or a percentage of the available width.) |
| styles= | The default styles of tabs, Contents, etc. are defined in a global style sheet in file OnlineComm.css . Obviously, this means that all tabs will have the same layout (white background when active, gray background else). If you want a more elaborate layout of your tabs, you can achieve that by:
|
| conts= | By default, the Contents associated with a tab are identified by their sequence in document.all . This works fine usually, and it can save you from coding identifiers. However, if you have several nested Tabs controls in your document, this method might go wrong. Then you can help yourself by coding this option before calling function Tabs() , and coding an identifier to each Contents. Example: ID=" 1", ID=" 2", ID=" 3" ( being the same char sequence as in the option declaration) |
| id= | By default, function Tabs generates the tabs without identifiers. Thus you can have multiple Tabs controls within one document, without caring about potentially conflicting id names. However, sometimes it might be useful if you have identified tabs (for example, if you want tabbing programmatically or for initializing.) |
| cont= | By default, the association between a tab and the pertaining Contents is established by the sequence in the all collection of the HTML document: the first object with CLASS="Cont" is associated with the first tab, the second Cont encountered in all is associated with the second tab, etc. In most applications of a Tabs control this will work fine, even if the last Contents has another Tabs control nested within. In a very complex Tabs control, however, you will need this option for "explicit association": tab 1 will be associated with an object that has ID=" 1" , tab 2 with the object ID=" 2" , etc. (with " " being the char sequence defined by option cont= , with the suffix 1 , 2 , etc. attached. |
| openall | If you want to produce a very user-friendly HTML document, you should provide an easy way to prepare it for searching a word and for printing it out altogether. By this option you can do that: A small green button ("OpenAll") is created after the last tab. When the reader clicks it, all information hidden in your document is displayed, and the button turns into "CloseAll" on red background. When clicking this button, all the contents are hidden again, ready for the normal tabbing to be resumed. |
A Tabs control is meant for tab-selecting by the user, simply by clicking a tab = having the associated Contents appear on screen. Sometimes, however, you will want to select a tab by your coding.
You can do that by calling function handleTab() with one parameter, the identifier of the tab to be selected.
Then however, the Tabs control must have been called with option id= (see other options).
Here you have an example of tabbing (= selecting a tab) by a pseudo-link. It is coded as follows (but remember):
The Tabs control was called by
"Option" is the third tab. So to select it, function return handleTab(tab3) must be called. For not to jump to the begin of document when the user is clicking the link, false must be returned (which happens to be the return value of function handleTab() ).
In order to have a perfect Tabs layout right when it comes up on screen, each Tabs control must be initialized. You can do that by calling function handleTab() by an attribute in the BODY-tag of your HTML document:
Call the function with 1 parameter, the id of the tab to come up with. For details see Tabbing.
A frequent source of errors is to have a block tag opened before calling Tabs, but not closed before. While this is irrelevant for the normal browser operations, it might have its effect in Tabs. For example, you might have opened a FONT-tag (deliberately not closing it!) right before the first line of your document. Thus you have changed all your BODY-font, Ok. However, it's distorting the positioning of Cont's done in function handleTab() .
Better you do it by a STYLE attribute in your BODY-tag, e.g.:
<DIV CLASS="Cont">
:
</DIV>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
(text to follow)
You will want to make the user forget about the loading time (see article Make Your Visitor forget about Loading Time!). To that end, it is a good idea to always initialize on the first tab. Then, while the browser is still loading all the stuff of the other tabs, your users have all the information of the first tab on screen already. So they have something to read and don't care about the fact that the browser is still loading. Later, when clicking another tab, its contents are already loaded - they are on screen instantaneously.
If the information you want to refer to be within another Contents, you can refer to it by a pseudo-link calling the tabs handler function with the id of the tab associated to your tab's contents as parameter. For example, if we needed a reference to the Options tab, we could do that by a hyperlink linking nowhere but calling the handler function:
The individual tab labels should be short, possibly one word only. You can make it user-friendlier if you provide a TITLE to each tab. That's a pop-up window coming up on screen when the user moves the cursor onto a tab and has it rest there for about ½ When the cursor is moved away or when the tab is clicked, it's being closed again. You can use the option titles= to provide a brief description of what the tabs are about (see
The Tabs control is a very useful tool for compact presentation of masses of data, all within one screen only. Yet there are some instances when your readers will want to have all the information on screen temporarily, e.g. for searching any keyword (keys: CTRL-F) or for printing out all your information (keys: CTRL-P). And, after all, at one point you will want to have it all on screen, too: when you are finished with writing and want to copy your text to spell-checking.
You can provide an easy way to do that, simply by setting option openall before calling function Tabs() .
Due to this option, an image "OpenAll" on green background is created. When a reader clicks on this image, the full information is expanded and the image turns to "CloseAll" on red background. Clicking on it removes all the Contents, leaving the tabs only. By clicking on any tab, the usual tab-wise presentation can be resumed.
You can get a hands-own experience: Look at the tab row above, after the last tab. When you click on the green button there, all information of this article will be expanded. You can see it by watching the scroll bar at the right screen edge. Then it turns to a red switch. Clicking on it removes all the information, leaving only the tabs on screen. Then you should simply click the tab you are interested in next.
It's a good idea to write a title to each Contents (= the information associated with a tab):
Temporary information is a major part of the Tabs control concept. That is information which is hidden most of the time. Not before the reader clicks the "anchor" (such as the line above: "In your HTML, ") the associated information is displayed temporarily whereas all the surrounding information is hidden, thus always occupying not more than one screen.
An example of temporary information you have right before your eyes currently!
When the reader clicks the "anchor" once more, the temporarily displayed information is hidden again, the surrounding information is restored.
When you have such an information, you should always declare it
Currently this is needed only to hide all temporary information when the "CloseAll" button is clicked. Future developments will assume that all temporary information is declared this way, and will use it for its handling.
So, you can be rather on the safe side if you exert some discipline now already!
If you have many tabs, perhaps even in several tab rows, it might be helpful to your readers if you present the associated information ("Contents") on different background colors. Once a tab has been clicked, i.e. the Contents has been opened, the pertaining tab will be set to the same background color, even when another tab is clicked afterwards.
This color could prove a good help to your readers for memorizing a tab: "What I would like to see now, I remember having seen on background already. So I should click now the tab with the same background color!"
<SCRIPT SRC="../JS/OnlineComm.js"></SCRIPT> <SCRIPT SRC="../CSS/OnlineComm.css"></SCRIPT>
A Tabs control can be implemented by calling it in <SCRIPT>-brackets, i.e.
If you want to use options, they must be assigned to before calling Tabs and must be separated by a semicolon - e.g.
You can have more than one Tabs control in an application. If so, however, make sure that they have different id's, if any.