JS image pre-loaded JS implementation of the picture preload application _javascript skills

Source: Internet
Author: User

Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
&LT;TITLE&GT;JS implementation of the picture preload after loading action </title>
<style type= "Text/css" >
<!--
*html{
margin:0;
padding:0;
border:0;
}
body{border:1px solid #f3f3f3; background: #fefefe}
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]= "Yun_qi_img/baidu_logo.gif";
Imgarr[1]= "Yun_qi_img/logo-img.gif";
Imgarr[2]= "Yun_qi_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 action here,
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.