Table of Contents Generator is a small script I wrote to create a table of contents based off of the header tags(h1-h6) throughout a page. In fact I wrote it for this very site.
Browser Support
This script has been found to work in IE5+,Safari,Firefox 1+, and Opera 7+. If you are viewing this page in another browser, and it works, feel free to tell me about it in the comments.
Demo
The demo above is generated dynamically based of off this page. This is script is also used on every page of this site to generate that table of contents found when you click on the "Table Of Contents" link found near the top of the page.
Usage
Here I will go over how to use the script
Download
First of all you need to download the single javascript file here. Save this as toc.js in the same directory as the file you would like to use it on.
Adding the code
Then, in the head of that file add this.And in the body add this(where you want the Table to appear)
The part you need to edit is this(second line of toc.js)
Change top to the id of the element you want the table to based off of(all the header tags must be direct descendants), and toc to the id of the div you added to the body.If you followed these directions exactly you don't need to change toc.
Questions?
Feel free to ask in the comments
Warning: WARNING: Comments is not properly cleaning input params. in /home/freegam4/public_html/webtech/lib/classes/class.module.inc.php on line 1500
Comments
Thanks for the info Sam. I have updated the page.
works in safari on mac
Does not work in IE6.
The menu on the left isd really buggy when you resize the browser window.