开发者

Page Loading Screen in PHP

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?


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}


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
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜