views:

186

answers:

2

Hi all, I am working on a Php page which loads more images,so I want to show the User as the Page is currently Loading. I have tried but it does not working correctly.

The loading image should be run until all image gets load.How to implement for this?

+1  A: 

Try window.onload event. An example:

// Plain old javascript
window.onload = function() {
    hideLoadingIndicator();  // function defined by you
}

// jQuery
$(window).load(function() {
    hideLoadingIndicator();  // function defined by you
});
jholster
+1  A: 

You could consider output buffering.

Example:

Output this first:

<div id="loading"><img src="{loading-img}" /></div>

Then buffer rest of output and send send when ready to the browser by flushing it.

When this ouput is rendered in the browser you can use an inline style to hide the previous html block.

Example in the second output.

<style>
div#loading { display:none; } 
</style>
{REST_OF_HTML_TO_BE_RENDERED}
andreas