First create your HTML. You can style it however you want but the division names must remain the same.
<div id='indexDiv'> <div id='indexContents'></div> </div>
Next place the following code at the end of your content.
els=document.getElementsByTagName('h4'); idx=''; for (i=0; i<els.length; i++) { idx += '<a href="#quickIDX'+i+'">'+els[i].innerHTML+'</a><BR>'; els[i].innerHTML='<a name="quickIDX'+i+'"></a>'+els[i].innerHTML; } if (!els.length) { document.getElementById('indexDiv').style.display='none'; } else { document.getElementById('indexContents').innerHTML=idx; }
Any H4 tag on the page will now be indexed and a link to the element placed in the index the script built. Place the index anywhere on your page and style it however you wish.