js图片预加载实现!


var myImage = (function(){   var imgNode = document.createElement( 'img' );   document.body.appendChild( imgNode );     return {       setSrc: function( src ){        imgNode.src = src;       }     } })();
var proxyImage = (function(){   var img = new Image;   img.onload = function(){     myImage.setSrc( this.src );   } return {   setSrc: function( src ){     myImage.setSrc( 'file:// /C:/Users/svenzeng/Desktop/loading.gif' );     img.src = src;   } } })(); proxyImage.setSrc( 'http:// imgcache.qq.com/music/photo/k/000GGDys0yA0Nk.jpg' );

  

posted @ 2017-06-07 14:26  惊蛰1993  阅读(534)  评论(0编辑  收藏  举报