August 19, 2005

0xCAFE, er, -script

I've gotten so accustomed to the table of contents on Wikipedia pages that I expect them to be there, even on simple hand-coded web pages, so I cobbled together some JavaScript to walk the top level of a document and find the h2, h3, .. h6 headings and magically make a TOC. The actual list generation code originally came from QuirksMode, and I borrowed chunks from Wikipedia for the show/hide functionality. Layout of the elements is essentially the same as in Wikipedia, other than the fact that I use a 'span' or something somewhere instead of an 'h2', since fixing that probably would have required some specila logic. Anyway, check it out here (view source if you want the code).

Oh look, I forgot about that tag the U adds to static HTML pages... So, here is how it should really look...

Posted by mike at August 19, 2005 12:52 AM | Internet
Comments
Post a comment









Remember personal info?