JS page load progress bar code
<script language= "JAVASCRIPT" >
var timerid=null; <!--delay variable-->
var count=0; <!--loop variable for Progress-->
var Running=false; <!--The amount of--> that is being formatted
function Randomnumber (max) <!--functions used to produce random numbers-->
{var today = new Date (); <!--Create a time Date object-->
var num= math.round (Math.Abs (Math.sin (Today.gettime ()) *1000))%max+1; <!--uses the current time date value to take certain algorithm to produce the random number, in which the decimal part is processed according to the rounding rule-->
return num;
}
Function stopaction () <!--function to stop the formatting operation;
{if (running) <!--If you are formatting, clear the Timerid delay operation;
cleartimeout (Timerid);
running=false; <!--Set the flag variable to False-->
}
function StartAction () <!--functions used to begin formatting operations-->
{stopaction (); <!--stop formatting operations-->
Action (); <!--formatting operations-->
}
Function action ()
{if (count!=100) <!--If the format progress is less than 100, the percentage that has been completed is displayed-->
{document.outputform.output.value= "is downloading the file, current progress:" +count+ "%";
count++; <!--count Plus 1-->
Timerid=settimeout ("Action ()", 200+randomnumber (500)); <!--call the random number generation function to calculate and set the delay length-->
Running=true; <!--Mark Quantity is true-->
}
Else
{document.outputform.output.value= "Download complete ..."; <!--If the format progress is 100, the display format is finished-->
Stopaction (); <!--stop-->
}
}
</script>
<body onload= "startaction ()" >
<form name= "Outputform" >
<p><input type= "TEXT" name= "Output" size= "></p>"
</form>
<!--This case simulates a progress bar feature for a formatted hard drive-->
The progress of the <!--format is computed by a random number of-->
<!--This random number is based on a certain calculation rules for the current system of processing the time-->
<!--indicates that the format is complete when the progress is 100-->