Copy code The code is as follows: .org/1999/xhtml"> < title>js implements image preloading and performs actions after loading <br><!-- <BR> >*html{ <BR>margin:0; <BR>padding:0; <BR>border:0; <BR>} <BR>body{border:1px solid #f3f3f3; background:#fefefe} <BR>div #loading{ <BR>width:950px; <BR>height:265px; <BR>line-height:265px; <BR>overflow:hidden; <BR>position:relative; <BR>text-align:center; <BR>} <BR>div#loading p{ <BR>position:static; <BR> position:absolute; <BR>top:50%; <BR>vertical-align:middle; <BR>} <BR>div #loading p img{ <BR>position:static; <BR> position:relative; <BR>top:-50%;left:-50%; <BR>vertical-align:middle <BR>} <BR>- -> <br> <br>var i=0; <br>var c=3; <br>var imgarr=new Array <br>imgarr[0]="http://www.baidu.com/img/baidu_logo.gif"; <br>imgarr[1]="http://img.baidu.com/img/logo-img .gif"; <br>imgarr[2]="http://img.baidu.com/img/logo-zhidao.gif"; <br>var Browser=new Object(); <br>Browser.userAgent= window.navigator.userAgent.toLowerCase(); <br>Browser.ie=/msie/.test(Browser.userAgent); <br>Browser.Moz=/gecko/.test(Browser.userAgent); <br>function SImage(url,callback) <br>{ <br>var img = new Image(); <br>if(Browser.ie){ <br>img.onreadystatechange =function(){ <br>if(img.readyState == "complete"||img.readyState=="loaded"){ <br>ii=i 1; <br>callback(i); <br>} <br>} <br>}else if(Browser. Moz){ <br>img.onload=function(){ <br>if(img.complete==true){ <br>ii=i 1; <br>callback(i); <br>} <br> } <br>} <br>img.src=url; <br><br>} <br><br>function icall(v) <br>{ <br>if(v<c){ <BR>SImage ("" imgarr[v] "",icall); <BR>} <BR>else if(v>=c){ <br>i=0; <br>//location.replace('banner.html' );//Write your own actions here, <br>} <br>} <br><br> </div>