I'm trying to create a progress bar that increments every time a specific function, in this case "interval()" is called. When the code below executes, my progress bar goes straight from 0% to 100%. But, if I uncomment the 'alert()' line, it works perfectly (except for the alert box).
Here's a link to a page with this code:
[click here]
Any insights into my dilemma will be much appreciated.
// JS Code follows * * * *
function interval () {
var progWidth = Math.round ( 100 / document.numIntervals * ( ++document.curInterval ) );
document.all [ "percent" ].innerText = progWidth + "%";
document.all [ "progress" ].width = Math.round ( progWidth * .85 ) + "%";
//alert ( progWidth );
}
function doStuff () {
// Number of times interval() is called is calculated
document.numIntervals = 25;
document.curInterval = 0;
setTimeout ( "interval()", 1000 );
setTimeout ( "interval()", 1000 );
for ( var i = 0; i < document.numIntervals - 2; i++ ) {
setTimeout ( "interval()", 1000 );
}
return ( true );
}