August 28, 2004 4:41 PM
On my first website, Javascript routines littered almost every page. The most useful of those scripts were the loading indicator which was my attempt at simulating a "Loading" progress bar for a web page.



<form name="clkform" action="javascript:void(0);">
<input name="clk" size="25" 
type="text" value="Loading ----"/>
<script language="Javascript" type="">
var run=0,count=0;
orig=new Date();
var messages1=new Array("Loading ----",
                        "Loading |---",
                        "Loading ||--",
                        "Loading |||-",
                        "Loading ||||");

function GetIndex1() 
else return(count++);}

function doload()
window.setTimeout("doload();", 500);}}

function loaded(){
var today;today=new Date();
document.clkform.clk.value="Loaded in "+run+" seconds.";

Put the above code fragment in your page in the beginning of your page after the body tag. Then add an onLoad attribute to your body tag so that it looks like so:

<body onLoad="loaded();">

If you do not prefer the onLoad method, you can always keep a call to loaded() at the end of your page below the closing body tag using script tag instead:

<script language="Javascript" type="">loaded();</script>


Copyright © 2004-2011 Anirudh Sasikumar. All rights reserved.
Last Updated: January 21, 2005 4:28 PM