js预处理图片个人见解1

 1 <!doctype html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>js处理预加载图片</title>
 6 </head>
 7 <img src="http://static.googleadsserving.cn/pagead/imgad?id=CICAgKDTydS8JhCsAhj6ATIIRJtOOsejnHk" alt=""/>
 8 <img src="http://www.jb51.net/images/logo.gif" alt=""/>
 9 <img src="http://imglf1.nosdn.127.net/img/Z09yMllJWHpmK2NBcnB4M2lKOFRHK2d1azFNSmFveVE1OG8vTmVJNXhZYnhycGFzOXhqckZ3PT0.jpg?imageView&thumbnail=2000y1235&type=jpg&quality=96&stripmeta=0&type=jpg" alt=""/>
10 <img src="http://imgcdn.ph.126.net/OR2duCBCm0pSFr-J9FaApg==/6631284369490579486.jpg" alt=""/>
11 <img src="http://imgcdn.ph.126.net/TjjGrghOlZKwrarCHGFEMQ==/294704300716273180.jpg" alt=""/>
12 <img src="http://imglf2.nosdn.127.net/img/SVRrRE5mVzEvM0FRWGZSQ1RYSmdkNXFlNmhQWWRrRmdyU0N1TXdnd05KUWhNY3BRSXV3MUJRPT0.jpg?imageView&thumbnail=2000y1329&type=jpg&quality=96&stripmeta=0&type=jpg" alt=""/>
13 <img src="http://imgcdn.ph.126.net/czn-UyCIDqKOQbNknCSbpg==/3750935539746209461.jpg" alt=""/>
14 <body>
15 <script>
16     var arr1 = [
17             "http://static.googleadsserving.cn/pagead/imgad?id=CICAgKDTydS8JhCsAhj6ATIIRJtOOsejnHk",
18             "http://www.jb51.net/images/logo.gif",
19             "http://imglf1.nosdn.127.net/img/Z09yMllJWHpmK2NBcnB4M2lKOFRHK2d1azFNSmFveVE1OG8vTmVJNXhZYnhycGFzOXhqckZ3PT0.jpg?imageView&thumbnail=2000y1235&type=jpg&quality=96&stripmeta=0&type=jpg",
20             "http://imgcdn.ph.126.net/OR2duCBCm0pSFr-J9FaApg==/6631284369490579486.jpg",
21             "http://imgcdn.ph.126.net/TjjGrghOlZKwrarCHGFEMQ==/294704300716273180.jpg",
22             "http://imglf2.nosdn.127.net/img/SVRrRE5mVzEvM0FRWGZSQ1RYSmdkNXFlNmhQWWRrRmdyU0N1TXdnd05KUWhNY3BRSXV3MUJRPT0.jpg?imageView&thumbnail=2000y1329&type=jpg&quality=96&stripmeta=0&type=jpg",
23             "http://imgcdn.ph.126.net/czn-UyCIDqKOQbNknCSbpg==/3750935539746209461.jpg",
24     ];
25     function loadimg(){
26         var t = 0;
27         Oimg = document.getElementsByTagName("img");
28         for(var i=0;i<Oimg.length;i++){
29             Oimg[i].onload = function(){
30                 if(t == Oimg.length-1){
31                     alert("加载完成");
32                 }else{
33                     t++;
34                 }
35             }
36         }
37     }
38 loadimg();
39 </script>
40 </body>
41 </html>

 

posted @ 2015-10-22 13:50  挥刀  阅读(351)  评论(0编辑  收藏  举报