0

打开页面时出现问题,我需要在打开页面之前打开加载图像,我该怎么做

    <style>
#dvLoading
{
   background:#000 url(images/ajax-loading.gif) no-repeat center center;
   height: 100px;
   width: 100px;
   position: fixed;
   z-index: 1000;
   left: 50%;
   top: 50%;
   margin: -25px 0 0 -25px;
}
</style> 

$(window).load(function(){
  $('#dvLoading').fadeOut(2000);
});
4

2 回答 2

0

window.load将等待整个内容加载,然后触发它。你最好使用'ready',即:

<style>
#dvLoading{
   background:#000 url(images/ajax-loading.gif) no-repeat center center;
   height: 100px;
   width: 100px;
   position: fixed;
   z-index: 1000;
   left: 50%;
   top: 50%;
   display: none;
   margin: -25px 0 0 -25px;
}
</style> 
$(function(){
  $('#dvLoading').css('display', 'block');
});

$(window).load(function(){
  $('#dvLoading').fadeOut(2000);
});

<div id="dvLoading"></div>在收盘前</body>

于 2012-11-25T08:44:08.907 回答
0

尝试这个:

$(window).bind("load", function() {
    $('#dvLoading').hide();
});

演示在这里

于 2012-11-25T11:46:43.557 回答