tags:

views:

4641

answers:

3

Hi, I want to have an animated GIF image to appear or load whenever my .aspx page (for my appln) is loaded or postaback or some background process is going on::

<div id="WaitDialog" style="left: 480px; top: 255px; position: absolute">

<img src="http://developers.sun.com/docs/web-app-guidelines/uispec4_0/progress_graphics/asynch-1F.gif" />
<FONT size=3 class="text3" ><font color="black">Loading, Please Wait.</font></FONT>

</div>

function ProgressBar()
{
  var dialog = document.getElementById("WaitDialog");
  dialog.style.visibility = 'hidden';
  scrollTo(0,0);
}

........ this animated image should load just like as browser progress bar progresses and if I perform any validations in database (DB operations say), then also the image should load...

1) I'm not using AJAX for my application so I dont want AJAX to come into picture too...

2) the image should appear as when the page started loading...

i.e. Something is goin in progress in tha background and the .gif image should load

How can i write the code accordin to tht as now i have a Javascript function ProgressBar() which i invoke by having onSubmit="ProgressBar()" in body tag.....

Can any1 help me in this ?

+3  A: 

With the following code, your image is already visible by default, it gets hidden when the page is fully loaded. It gets shown when a form submit happens.

Then when the postback ocurrs, the image will still be visible, then it gets hidden with window.onload() which fires when the browser has finished loading all the elements.

<head>
<script type="text/javascript">
    window.onload = function (){  //hide onload
           var dialog = document.getElementById("WaitDialog");  
           dialog.style.display = 'none';  
           scrollTo(0,0);
    }
    function showProgressBar(){ //show on submit
        var dialog = document.getElementById("WaitDialog");  
        dialog.style.display = 'block'; 
    }
</script>
</head>
<body>
<div id="WaitDialog" style="left: 480px; top: 255px; position: absolute">
  <img src="http://developers.sun.com/docs/web-app-guidelines/uispec4_0/progress_graphics/asynch-1F.gif" />
 <font size=3 class="text3" >
  <font color="black">Loading, Please Wait.</font>
 </font>
</div>
<form onsubmit="showProgressBar()">
  .... all the ASPX controls and stuff
</form>
</body>
</html>
ichiban
A: 

You're going to have issues creating it on load.

For unload, throw that in the body onunload:

<body onunload="javascript:ProgressBar()">
Luke Schafer
A: 

Thanx. alot..its work man..

sheery