Full version: jsB@nk » Menu » Navigation » Page Index
URL: https://www.javascriptbank.com/page-index.html
This is an incredibly simple script. It pulls each H4 element and creates a clickable index to it. It stuffs the headings it finds in a division named indexDiv and if it didn't find any H4 tags it will even make the indexDiv invisible. You can also change it to use any other heading element.
Full version: jsB@nk » Menu » Navigation » Page Index
URL: https://www.javascriptbank.com/page-index.html
<script language="javascript">// Created by: Patrick Hunlock | http://www.hunlock.com/function pageIndex() { var els=document.getElementsByTagName('h4'); if (!els.length) { document.getElementById('indexDiv').style.display='none'; } else { var 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; } document.getElementById('indexContents').innerHTML=idx; }}// Multiple onload function created by: Simon Willison// http://simon.incutio.com/archive/2004/05/26/addLoadEventfunction addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } }}addLoadEvent(function() { pageIndex();});</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<div style="width: 50%; text-align: left;"><div id='indexDiv'> <div id='indexContents'></div></div><H4>This is Section 1</H4><P>Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.</P><H4>This is Section 2</H4><P>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</P><H4>This is Section 3</H4><P>Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.</P></div><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->