Click here to Skip to main content
15,886,799 members
Articles / Web Development / HTML
Tip/Trick

HTML 5 Progress Bar For Progressive JavaScript Events Processing

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
4 Dec 2012CPOL 31.2K   11   3
Try this block of HTML 5 code

Create a new HTML file and copy the following code to see the result in your browser 

<html>
 <title>HTML 5 Progress Bar For Progressive Javascript Events Processing</title>
 <body>
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
<span id="status"></span>
<h1 id="finalMessage"></h1>
<script type="text/javascript" language="javascript">
function progressBarSim(al) {
  var bar = document.getElementById('progressBar');
  var status = document.getElementById('status');
  status.innerHTML = al+"%";
  bar.value = al;
  al++;
	var sim = setTimeout("progressBarSim("+al+")",300);
	if(al == 100){
	  status.innerHTML = "100%";
	  bar.value = 100;
	  clearTimeout(sim);
	  var finalMessage = document.getElementById('finalMessage');
	  finalMessage.innerHTML = "Process is complete";
	}
}
var amountLoaded = 0;
progressBarSim(amountLoaded);
</script>
</body> 
</html>     

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Kuwait Kuwait
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Nitesh Maharaj4-Dec-12 21:48
Nitesh Maharaj4-Dec-12 21:48 
SuggestionStuff I had to do to get it to work Pin
Nathaniel A Collier4-Dec-12 6:45
Nathaniel A Collier4-Dec-12 6:45 
GeneralRe: Stuff I had to do to get it to work Pin
Emad Al Hawary4-Dec-12 21:18
Emad Al Hawary4-Dec-12 21:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.