<! PUBLIC DOCTYPE HTML "-///DTD/W3C 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 to realize image preload after the load action </TITLE>
</HEAD>
<Style type="text/CSS" >
<! -
{* HTML
margin: 0;
the padding: 0;
border: 0;

} body {border: #1px solid f3f3f3; Background: #fefefe}
div #loading {
width: 950px;
height: 265px;
the 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> <Img SRC="http://www.baidu.com/img/baidu_logo.gif"/></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 (); .
the userAgent=window. The navigator userAgent. ToLowerCase ();
the ie=/msie/. The test (the userAgent);
the Moz=/gecko/. The test (the userAgent);
function SImage (url, callback)
{
var img=new Image ();
if (the ie) {
img. The onreadystatechange=function () {
if (img. ReadyState=="complete" | | img. The readyState=="the loaded") {
ii=I + 1;
callback (I);

}}
} else if (the Moz) {
img. Onload=function () {
if plete==true (img.com) {
ii=I + 1;
callback (I);

}}

} img.src=http://www.script-home.com//article/url;

}

function best (v)
{
if (v SImage (" "+ imgarr [v] +", "best);

} else if (v> c)={
I=0;
//location. The replace (' banner. HTML ');//here to write your own actions,

}}

you might be interested in the article:

  • javascript using Image object point of buried somewhere (clicks) statistical
  • js to realize Image preload (onload js operation complete Image object attribute, asynchronous loading picture)
  • js to realize Image preload without waiting for
  • about the images in the process of the preloading hidden unknown
  • jQuery Image preloading geometric scaling implementation code
  • javascript event loaded with preloaded
  • jQuery Image preloading such as automatic proportioning plug-in
  • javascript also play Image preloading
  • js images by using Image objects, preload improve access speed


This concludes the body part