Method 1:
<HTML>
<Head>
<SCRIPT type = "text/JavaScript">
VaR mytimer = NULL; var bar = 0;
Function processbar (){
If (Bar <200 ){
Bar ++;
Document. getelementbyid ("processbar"). style. width = BAR + "PX ";
Mytimer = Window. setTimeout ("processbar ()", 50 );
}
}
Function startbar (){
Mytimer = Window. setTimeout ("processbar ()", 50 );
}
Function pausebar (){
Window. cleartimeout (mytimer );
}
</SCRIPT>
</Head>
<Body>
<Div style = "width: 200px; Height: 10px; Border: solid 1px # CCC; padding: 1px;">
<Div id = "processbar" style = "background-color: #90ee90; width: 0px; Height: 10px;"> </div>
</Div>
<Input type = "button" value = "start" onclick = "startbar ();"/>
<Input type = "button" value = "pause" onclick = "pausebar ();"/>
</Body>
</Html>
Method 2:
<HTML>
<Head>
<SCRIPT type = "text/JavaScript">
VaR mytimer = NULL; var bar = 0;
Function processbar (){
If (Bar <200 ){
Bar ++; document. getelementbyid ("processbar"). style. width = BAR + "PX ";
}
}
Function startbar (){
Mytimer = Window. setinterval ("processbar ()", 50 );
}
Function pausebar (){
Window. clearinterval (mytimer );
}
</SCRIPT>
</Head>
<Body>
<Div style = "width: 200px; Height: 10px; Border: solid 1px # CCC; padding: 1px;">
<Div id = "processbar" style = "background-color: #90ee90; width: 0px; Height: 10px;"> </div>
</Div>
<Input type = "button" value = "start" onclick = "startbar ();"/>
<Input type = "button" value = "pause" onclick = "pausebar ();"/>
</Body>
</Html>