Copy codeThe Code is as follows: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> js implements the action after image pre-loading is completed </title>
</Head>
<Style type = "text/css">
<! --
* Html {
Margin: 0;
Padding: 0;
Border: 0;
}
Body {border: 1px solid # f3f3f3; background: # fefefefe}
Div # loading {
Width: 950px;
Height: 265px;
Line-height: 265px;
Overflow: hidden;
Position: relative;
Text-align: center;
}
Div # loading p {
Position: static;
+ Position: absolute;
Top: 50%;
Vertical-align: middle;
}
Div # loading p img {
Position: static;
+ Position: relative;
Top:-50%; left:-50%;
Vertical-align: middle
}
-->
</Style>
<Div id = "loading">
<P> </p>
</Div>
<Script>
Var I = 0;
Var c = 3;
Var imgarr = new Array
Imgarr [0] = "http://www.baidu.com/img/baidu_logo.gif ";
Imgarr [1] = "http://img.baidu.com/img/logo-img.gif ";
Imgarr [2] = "http://img.baidu.com/img/logo-zhidao.gif ";
Var Browser = new Object ();
Browser. userAgent = window. navigator. userAgent. toLowerCase ();
Browser. ie =/msie/. test (Browser. userAgent );
Browser. Moz =/gecko/. test (Browser. userAgent );
Function SImage (url, callback)
{
Var img = new Image ();
If (Browser. ie ){
Img. onreadystatechange = function (){
If (img. readyState = "complete" | img. readyState = "loaded "){
Ii = I + 1;
Callback (I );
}
}
} Else if (Browser. Moz ){
Img. onload = function (){
If (img. complete = true ){
Ii = I + 1;
Callback (I );
}
}
}
Img. src = url;
}
Function icall (v)
{
If (v <c ){
SImage ("" + imgarr [v] + "", icall );
}
Else if (v> = c ){
I = 0;
// Location.replace('banner.html '); // write your own actions here,
}
}