A simple progress bar demo.
<!doctype html>varT;functions (c) {if(c<=100) {Val.style.width=c+ "%"; Percent.innerhtml=c+ "%"; Btn.disabled=true; Btnp.disabled=false; C=c+10; T=settimeout ("s (" +c+ ")", 500); } Else{cleartimeout (t); Btnc.disabled=false; Btnp.disabled=true; return; }}functionC () {cleartimeout (t); Val.style.width= "0px"; Percent.innerhtml= "0%"; Btn.disabled=false; Btnc.disabled=true; Btnp.disabled=true; Btnp.value= ' Pause ';}functionp () {vartemp; if(' Pause ' = =btnp.value) {cleartimeout (t); Btnp.value= ' Go on '; Btnc.disabled=false; } Else{Temp=Val.style.width; Btnp.value= ' Pause '; vark=parseint (Delend (temp)); S (k); Btnc.disabled=true; } }functiondelend (str) {varTemp= ""; for(vari=0; i < str.length-1; i++) {Temp=temp+Str[i]; } returntemp;}</script>Feel:
1. In a simple page, inside the <script> tag, you can use the ID to represent a control directly, without using document.getElementById ().
2.setTimeout () commands can be used for string concatenation
JavaScript progress bar