What is domTab?

domTab is a Javascript that turns a navigation list linked to anchored elements into a tabbed interface. It loops through all the links of the navigation, adds the necessary event handlers and hides all the elements but the first one. If the elements have a link back to the menu, domTab removes these for you. Furthermore, it adds a highlight class to the link of the first element. When a user clicks on any of the links, domTab hides the previously visible section and removes the highlight class of the old link, and shows the new section and adds the highlight class to the active link.

You do not need to add any event handlers to your HTML.

back to menu

How to use domTab

To use domTab, all you need to do is to call it in the head of your HTML page:

<script type="text/javascript" src="domtab.js"></script>

Out-of-the box, domTab needs an element with the id mainnav to apply the functionality to. This id will be changed to mainnavtabbed if the browser is able to show the tabbing functionality. This means that you apply your styles for a normal link list to #mainnav and the styles for the tabs to #mainnavtabbed. domTab also adds a class named tabon to the active link in the navigation. If you need to overwrite the names of these ids and the class, you can change the variables navElement navElementTabbedId and tabHighlightClass in the code.

domTab comes with its own onload call, if you want to use it together with other scripts, you need to remove the window.onload=initTabs; line and call the function initTabs() when you load the page.

domTab automatically connects the links to the sections to hide via the href attribute of the link. This way you can add as many elements to the navigation as possible without any need to change the Javascript.

Furthermore, domTab deletes the last link inside the elements to be hidden, if this link points back to the menu via '#top'. If you want to use another anchor name for the beggining of your page, you can change the backToMenu variable.

Please ensure that each link does have a corresponding element with the right ID. domTab will not throw an error, but fail to hide the element.


	<ul id="mainnav">
	 <li><a href="#what">What is domTab?</a></li>
	 <li><a href="#how">How to use domTab</a></li>
	 <li><a href="#redesign">Redesigning domTab</a></li>
	 <li><a href="#failures">Failures and Issues</a></li>
	<div id="what">...
	<a href="#top">back to menu</a></div>
	<div id="how">...
	<a href="#top">back to menu</a></div>
	<div id="redesign">...
	<a href="#top">back to menu</a></div>
	<div id="failures">...
	<a href="#top">back to menu</a></div>

Automatic Highlighting

domTab automatically highlights the first element, if you want to change this behaviour, you can set the target in the URL.

In the above example a would highlight the failures tab.

Global Variables

To avoid a lot of looping and guessing of next and last siblings, domTab uses two global variables: currentTab, currentLink and tabHighlightClass. Please avoid using other scripts that use these.

back to menu

Redesigning domTab

domTab does not add any presentation to the markup, just functionality. The whole look and feel is kept in the Style Sheet. Initially, the main element needs to have an id of mainnav, which gets changed to mainnavtabbed and the class that gets added to the active link is called tabon. These settings can be overwritten by changing the variables in the source.

domTab comes with a demo CSS (this one), but you can choose any you want.

Good examples can be found at Listamatic's horizontal menu section.

back to menu

Please be also aware that every time you use a tabbed interface, you do simulate a "website in a page", which could lead to people getting frustrated trying to go back with the browser back button.

back to menu

back with the browser back button.

back to menu

shaeda afsharshagpilecavalier zoysiacavalier king charles rubber stampshake ya tail feather mp3junghans vienna regulatorshakespeareas you like itcaur audio equipmentshamrock design logoscaucasion mummies of chinashandi finnessey parentscaucasian mummies of chinajune maxam copyrightcatman cohen and the record industryjune conference/australiacathrine zeta jones nudecathren bellcatholicism religion judaism daoism religion reformedshariganjune 2006 idaho downwinderssharmane adamssharon marvel muscle video clipscathine bell4af enginesharps 4 barrel pocket pistolshauna obrianjumpstart 12 volt portable power supplyshb marketing tenbury wellscatchmaster adhesive fly trap glue manufacturerinterveiw questionsintervac vacuum5714 apple branch ct indianapolissheetrock dryingsheila aka luana lanishelburne farms cheddarshell atf specsjames sadler latte mugsshell silverstiensheltland sheepdog sheltie puppy for saleshelysa.rapozacaswell massey cucumber shea buttershenadoah inn vacastplanet.comshenley court schoolsheperds garden seedscastlerock landscaping blocksin flames soundscancastle snowmobile jacketscaster and camber adjustment platesjumelle dexcursion danime de gifs1999 suzuki 1100cc intruder specsshettles methodsheveluchcassie johnson curlingshikareecassandra peterson nudecassamarcashima uta mp3shimano fishing reels curado dshimatani hitomi mp3shimokawa mikuni mp3shiney rowcasius claycasiopea mp3casio fx-9750g plus date mode4ball tester4ball wear testerjuly 26th honoreeshirely chisholmshirinloushirley chislomcashelmara lodgeinterstate commerce railroad abandonments procedureshiv kumar batalvi mp3shnappicasey kasem audiosho omagarijulio cortazar axolotlcase - ruger small stockman knifecascuta seedcascadia every time we touchinterspousal immunityjuliet mcmainscasa iguana akumaljulien dassin avriljulien clerc mp3carved birch armoirejulie wotringshopsmith mark viijulie westeindeintersession prayershorewood loftsshorewood wi loftscartoon of riding lawn mowershort layered shag haircutshort-tailed chinchillacartersville georgia road runner high speed internetcarterfamily in maineshould cloning be alowedshoups country foodscarsoft bmw downloadcarrot soup john segalcarroll county newspaper in berryville arkansasinterracial tv/ts gang-bangsshrek 4d photocarri lee galleryshriekback mp3shrievescarravagiojulian ardellashurley methodcarpender beescarpe diem audrey walker the actressshyteenshyteensjulia roberts picture phinnaeussiberian huskeysjulia mosteroticteensaction aerating ornamentsjulia louis dreyfuss galleryjulia bikova mp3julia alanen63 pontiac catalinasideboysinterraciajules asner desnudasidi raptor evo bootcarnie wilson nudesiemens el34siemens sx1 powerlockcarmen serban mp3sifl olly mp3carmen electrcarmen elecrtasight proof louverscarmelita jetercarman elektrasigma rho chi recruitment counselorinterpreting bar graphs/middle schoolcarlos santana prospect pewtercarlos mercia no strings attachedsignature homes kiheicarlisle duro desert tiresignes du zodiaquescarlas thumbssignoria duvet covercarla markel gomezcarla kay dingercarl milam oklahomasil-std packagingcarina perellihotel motel dhaka bangladeshsilex laser technology uranium enrichmentsilica gel desiccantssiliconaturesilicone menstruation cupsinterpret wechsler scoressilk and taffeta rod pocket drapery panelscarflex connectorssilky terriorsilmetsilver beige adult poodlecareerbuilders.comjuhl loftssilver sow free teaser web cam girlssilver sparkle electromatic guitarsilver swirl hinged bangle braceletjuggies and lornainterplak replacement brushescare and breeding of the scarlet macawjug fuckers latinsimac ice cream mancardprosimarik mp3cardio strip aerobics1997 plymouth neon headlight housingjudy tayloursimpson large marge implantsjudy perlinsimpsonpornjudy katzeljudy jetson pornjudy jetson nudejudy halonesimpsonspornsimpsonssexsimpsonsxxxsims busten out cheats for ps21997 ls1 firebird enginesinan hoxha mp3singapore polytechnic girl sex videocaraquet hospitalsinger embroidery machine technical informationcaramichellesinghamjudie tzuke mp3sintecosinusitus treatmentsiofinternet4classrooms