hello world

图片预加载

当图片隐藏的时候方便预备加载

1.通过css

@media screen {
	div#preloader {
		position: absolute;
		left: -9999px;
		top:  -9999px;
		}
	div#preloader img {
		display: block;
		}
	}
@media print {
	div#preloader, 
	div#preloader img {
		visibility: hidden;
		display: none;
		}
	}

otherway
#element_01 {
	background: url(path/image_01.png) no-repeat;
	display: none;
	}
#element_02 {
	background: url(path/image_02.png) no-repeat;
	display: none;
	}
#element_03 {
	background: url(path/image_03.png) no-repeat;
	display: none;
	}

2
new image().src = "";
$(window).bind('load',function(){
    var station_imgs = new Array();
    $('.pop_img_show_up img').each(function(){
        station_imgs.push($(this).attr('src'));
    })
    $('.pop_img_show_down img').each(function(){
        station_imgs.push($(this).attr('src'));
    })
    var image_en = document.createElement('img');
        $(image_en).bind('load',function(){
            if(station_imgs[0]){
                this.src = station_imgs.shift();
            }
        }).trigger('load');
    
})
 
posted @ 2013-08-16 11:35  水御双氛  阅读(90)  评论(0编辑  收藏  举报