Progress bar while computing…

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.


No Responses to “Progress bar while computing…”  

  1. No Comments

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



Calendar

June 2005
M T W T F S S
    Jul »
 12345
6789101112
13141516171819
20212223242526
27282930  

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:

Archives


Categories

Tag Cloud


Listening