forked from qiqiboy/imageReady
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
47 lines (46 loc) · 2.31 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
<title>imageReady</title>
<script src="src/imageReady.js"></script>
</head>
<body>
<h1>imageReady test</h1>
<pre id="output">
</pre>
<p><script>document.write('<img id="img1" src="http://www.planeart.cn/demo/imgReady/vistas24.jpg?s='+Math.random()+'" />');</script></p>
<p><img src="images/1.jpg" /></p>
<p><script>document.write('<img id="img1" width="10" height="10" src="http://www.planeart.cn/demo/imgReady/vistas24.jpg?s='+Math.random()+'" />');</script></p>
<p><img src="images/2.jpg" width="200" height="400"/></p>
<script>
var imgs=document.images,
op=document.getElementById('output'),
i=0;
while(i<imgs.length){
imageReady(imgs[i++],function(){
op.innerHTML=op.innerHTML+((this.readyTime=+new Date)+'-<font color="green">ready</font>-'+this.src+'-'+this.width+'*'+this.height+'<br/>')
},function(){
op.innerHTML=op.innerHTML+(+new Date+'-<font color="blue">load</font>-'+this.src+'----------获取宽高时间节省'+(+new Date-this.readyTime)/1000+'秒<br/>');
},function(){
op.innerHTML=op.innerHTML+(+new Date+'-<font color="error">error</font>-'+this.src+'<br/>')
});
}
imageReady('http://www.planeart.cn/demo/imgReady/vistas24.jpg?s='+Math.random(),function(){
op.innerHTML=op.innerHTML+((this.readyTime=+new Date)+'-<font color="green">ready</font>-'+this.src+'-'+this.width+'*'+this.height+'<br/>')
},function(){
op.innerHTML=op.innerHTML+(+new Date+'-<font color="blue">load</font>-'+this.src+'----------获取宽高时间节省'+(+new Date-this.readyTime)/1000+'秒<br/>');
},function(){
op.innerHTML=op.innerHTML+(+new Date+'-<font color="red">error</font>-'+this.src+'<br/>')
});
imageReady('http://www.planeart.cn/demo/imgReady/vistas25.jpg',function(){
op.innerHTML=op.innerHTML+((this.readyTime=+new Date)+'-<font color="green">ready</font>-'+this.src+'-'+this.width+'*'+this.height+'<br/>')
},function(){
op.innerHTML=op.innerHTML+(+new Date+'-<font color="blue">load</font>-'+this.src+'----------获取宽高时间节省'+(+new Date-this.readyTime)/1000+'秒<br/>');
},function(){
op.innerHTML=op.innerHTML+(+new Date+'-<font color="red">error</font>-'+this.src+'<br/>')
});
</script>
</body>
</html>