I found this nice javascript that could be useful in places where some computing may take some time... Many application do intensive searches or computations, and it's better to give some feedback to the user while loading the results. You can try displaying a page with an animated GIF, and redirecting the page using something like:
<meta http-equiv="Refresh" content="0; URL="result-url">
But when the browser (IE) sends the request to "result-url", the GIF stops! Animated GIFs, seems to work for this purpose on Firefox and Opera, but not IE.
Here's a JavaScript solution:
<script language="javascript" type="text/javascript">
var SIZE=240;
var STEP=2;
window.onload = progress;
function progress(){
var bar=document.getElementById('progressbar');
bar.style.width=(parseInt(bar.style.width)+STEP)%SIZE;
setTimeout('progress()',40);
}
</script>
<div id="progressbar"
style="width:0px;height:10px;background-color:red;"></div>
Displaying an animated image could be easy replacing the "src" of an <img> element. I saw this technique by the JOnAS administrative console to reload periodically a server-side generated image that represent a graph of memory consumption. It just reload the image, without reloading the page. At first look it could seem an applet, but it isn't.
Search
Archives
Categories
- Android (3)
- Apple (27)
- Books (7)
- Eclipse (14)
- Errors (4)
- Firefox (7)
- Git (2)
- Hardware (17)
- Horror Code (8)
- Internet (21)
- Java (102)
- JavaScript (9)
- Life, universe and everything (46)
- Lifehacks (25)
- Linux (51)
- Opinions (26)
- OSX (6)
- Python (1)
- Software (31)
- Speeches and Conferences (8)
- Unix (4)
- Web (23)
- Windows (19)
Tag Cloud
Android apple architecture Bash configuration CSS Development Düsseldorf Eclipse Git Google Hardware hdr How-To Java JAXB job junit Karmic Linux lion MacBook music Open Source Opinion oracle OSX patterns Pitfalls Practices Resume Security Software Suspend TDD Testing tip tonemapped Tricks Ubuntu unix video Web Workaround XML
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Blog License
Blogs I like
Books on the desk
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- Simone Bruno
- Uberto Barbini
- Valvolog
- Webtide blogs (Greg Wilkins & Jan Bartel)
Links




















No Responses to “Progress bar while computing…”
Please Wait
Leave a Reply