1

I am using the following to show a loading image when something takes time to load.

<div class="divLoading"></div>

JS:

$("body").on({
    ajaxStart: function () {
        $(this).addClass("loading");
    },
    ajaxStop: function () {
        $(this).removeClass("loading");
    }
});

CSS

.divLoading {
    display:    none;
    position:   fixed;
    z-index:    1000;
    top:        0;
    left:       0;
    height:     100%;
    width:      100%;
    background: rgba( 255, 255, 255, .8 ) 
            url('../../Images/ajax-loader.gif') 
            50% 50% 
            no-repeat;
}  
body.loading {
    overflow: hidden;   
}
body.loading .divLoading {
    display: block;
}

But this is not working for the 1st time the page is loaded. I want to show this loading image as soon as I log in to my site, until the content of the page is loaded completely.Can you please help me on it. Thanks.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • http://stackoverflow.com/questions/1853662/how-to-show-page-loading-image-div-text-until-the-page-has-finished-loading-rend – Renjith Dec 19 '12 at 10:16

1 Answers1

0

Remember to put this code before closing head tag.

<script>
$(window).load(function(){
  $('#dvLoading').fadeOut(2000);
});
</script>
palaѕн
  • 72,112
  • 17
  • 116
  • 136