图片预装载弱化图片一张一张刷出的效果

来源:互联网 发布:lust extract mac 编辑:程序博客网 时间:2024/04/29 05:38

预加载是一项在需要图像之前就把它下载到缓冲区里的技术。通过这种方式,当真的需要图像的时候,它可以被从缓冲区里取出来,并立即显示出来。但是需要第一次调用图像的时候仍然会产生延迟,所以第一次只能弱化这种延迟的效果。

<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" errorPage="/jsp/pdssfw/web/common/errorpage.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%System.out.println("ddddddddsssssssssssssssssssss"); %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>::: P</title>

<script language="JavaScript">

   function preloader() {  

      imageobj = new Image();
      // set image list
 
      images = new Array();
images[0]="swf/profile.gif"  
                                                          
images[1]="swf/PersonnelInformationSystem.gif"                                           
images[2]="swf/deploymentTransfer.gif"                                                    
images[3]="swf/cm.gif"                                                                    
images[4]="swf/ae.gif"                                                                    
images[5]="swf/PerfomanceAppraisal.gif"                                                   
images[6]="swf/CompetencyEvaluation.gif"                                                  
images[7]="swf/SalaryEvaluation.gif"                                                      
images[8]="swf/grading.gif"                                                               
images[9]="swf/Compensation.gif"                                                          
images[10]="swf/oms.gif"                                                                   
images[11]="swf/orgment.gif"                                                               
images[12]="swf/jobMangent.gif"                                                            
images[13]="swf/staffing.gif"                                                              
images[14]="swf/staffing.gif"                                                              
images[15]="swf/recruitment.gif"                                                           
images[16]="swf/internalSourcing.gif"                                                      
images[17]="swf/outplacement.gif"                                                          
images[18]="swf/globalPosting.gif"                                                         
images[19]="swf/lp.gif"                                                                    
images[20]="swf/nextGeneration.gif"                                                        
images[21]="swf/toppotential.gif"                                                          
images[22]="swf/potentialDevelopment.gif"                                                  
images[23]="swf/leadershipDiagnosis.gif"                                                   
images[24]="swf/Hrsearch.gif"                                                              
images[25]="swf/Sharedvalue.gif"                                                           
images[26]="swf/nglc.gif"                                                                  
images[27]="swf/sgc.gif"                                                                   
images[28]="swf/ed.gif"                                                                    
images[29]="swf/js.gif"                                                                    
images[30]="swf/hrdSystem.gif"                                                             
images[31]="swf/generalManagement.gif"                                                     
images[32]="swf/hrerpSystem.gif"                                                           
images[33]="swf/Hrkip.gif"                                                                 
images[34]="swf/statusstatistics.gif"                                                      
images[35]="swf/HRDIAGNOSIS.gif"                                                           
images[36]="swf/HRKM.gif"                                                                  
images[37]="swf/hrPlaza.gif"                                                               
images[38]="swf/hrdpoint.gif"                                                              
images[39]="swf/manual.gif"                                                                
images[40]="swf/hrnetwork.gif"                                                             
images[41]="swf/faq.gif"                                                                   
images[42]="swf/NonExemptSystem.gif"                                                       
images[43]="swf/RDTechPeopleManagementSystem.gif"                                          
images[44]="swf/dearsamsung.gif"                                                           
images[45]="swf/sm.gif"                                                                    

    
 
      // start preloading
 
      for(i=0; i<=45; i++)
 
      {
           imageobj.src=images[i];
      }
      
          imageobj.onLoad=imagesLoaded();
  }
         function imagesLoaded()
         {
           document.location.href='/appHomeNext.do';
         }

  var i=1;
  function replay(){
     var obj=document.getElementById("wait");
     obj.innerHTML="Please wait, loading images...<br/>"+i;
     i++;
  }
  function pageinit(){
   setInterval(replay,1000);
   preloader();
  
  }
</script>
</head>
<body bgcolor="#ffffff" style='margin:5' onload="pageinit()">
  <p id="wait" align="center" valign="middle">Please wait, loading images...</p>
</body>
</html>