图片预加载

function loadImage(url, callback) {
    if(url!='null') {
        var img = new Image();
        img.src = url;
        if(img.complete) {
            callback(img);
        } else {
            img.onload = function(){
                img.onload = null;
                callback(img);
            } 
        }
    } 
}

loadImage(pic_url,loadImage);

  

posted @ 2014-04-25 15:17  hitbs228  阅读(94)  评论(0编辑  收藏  举报