step1:可以在网页里加一个div用来现实loading。
1 <div id="loading"> 2 <!--这里放你的loading时显示的动画或者文字--> 3 </div>
step2: 给这个loading div的样式
1 /*加载时全屏处于不能操作,只能处在loading动画的界面*/ 2 html,body{ 3 height:100%; 4 100%; 5 } 6 body{ 7 overflow: hidden; 8 } 9 #loading{ 10 100%; 11 height:100%; 12 color:#9f9f9f; 13 top:0px; 14 left:0px; 15 position:absolute; 16 z-index: 1999;/*用来显示在最前面*/ 17 text-align: center; 18 } 19 /*这里是页面正常显示部分,全部设为display:none*/ 20 .wrapper{ 21 display: none; 22 }
step3: 这里是jQuery代码
1 /*当页面加载完之后执行*/ 2 $(window).load(function(){ 3 $('#loading').fadeOut(); 4 $('body').css('overflow','scroll'); 5 $('.wrapper').fadeIn(); 6 });