|
TabInterface
This script generates all of the code necessary to create a tabbed interface.
Current Version0.3 (17 June 2007) RequirementsNone. LicenseTabInterface is distributed under the liberal MIT License. UseTo use, simply include TabInterface.js and then classify elements you want tabbed as "tabbed". Then add a new anonymous function to your load event (window or DOM). For example: if( typeOf( TabInterface ) != 'undefined' &&
document.getElementById &&
document.getElementsByTagName &&
document.createElement ){
var cabinets = Array();
/* using Jesse Skinner's addDOMLoadEvent()
http://www.thefutureoftheweb.com/blog/adddomloadevent */
addDOMLoadEvent( function(){
var collection = document.getElementsByTagName( '*' );
var cLen = collection.length;
for( var i=0; i<cLen; i++ ){
if( collection[i] &&
/\s*tabbed\s*/.test( collection[i].className ) ){
cabinets.push( new TabInterface( collection[i], i ) );
}
}
} );
}Many libraries, such as Prototype, offer nicer-looking means of collecting elements by CLASS and and those could certainly be substituted for the brute force testing seen above. Note: Tab labels will be either the header content or the heading's TITLE value. How it worksContent is split using the first heading level (H1-H6) encountered. DemoView the demo. Optimized Releases
Development VersionIf you are interested in helping to further develop this script, you can download the uncompressed JavaScript source file. Change Log
|
Sign in to add a comment
I have been trying desperately to implement this without success. I already have an onload function set up for other functions, and I can't tell if they are clashing. Either the function does nothing (content looks the same) or it completely disappears. I want to make the page accessible, but I am considering resorting back to less accessibility friendly scripts just to move on at this point.