Automatically Create a Page Index
First create your HTML. You can style it however you want but the division names must remain the same.
1 2 <div id='indexDiv'> 3 <div id='indexContents'></div> 4 </div>
Next place the following code at the end of your content.
1 2 els=document.getElementsByTagName('h4'); 3 idx=''; 4 for (i=0; i<els.length; i++) { 5 idx += '<a href="#quickIDX'+i+'">'+els[i].innerHTML+'</a><BR>'; 6 els[i].innerHTML='<a name="quickIDX'+i+'"></a>'+els[i].innerHTML; 7 } 8 if (!els.length) { 9 document.getElementById('indexDiv').style.display='none'; 10 } else { 11 document.getElementById('indexContents').innerHTML=idx; 12 }
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.