js-页面进入时同时实现-图片预加载
下面的是我认为最简单的预加载图片里!在页面进入时就开始加载
var imgARR = ['images/xmImg1.png','images/xmImg2.png','images/xmImg3.png','images/xmImg4.png','images/xmImg5.png','images/xmImg6.png',
'images/xgimg1.png','images/xgimg2.png','images/xgimg3.png','images/xgimg4.png','images/xgimg5.png','images/xgimg6.png','images/dlimg14.png',
'images/dlimg1.png','images/dlimg2.png','images/dlimg3.png','images/dlimg4.png','images/dlimg5.png','images/dlimg6.png''images/dlimg7.png','images/dlimg8.png',
'images/dlimg9.png','images/dlimg10.png','images/dlimg11.png','images/dlimg12.png','images/dlimg13.png','images/ljimg1.png','images/syimg1.png','images/syimg2.png',
'images/syimg3.png','images/syimg4.png','images/syimg5.png','images/syimg6.png','images/syimg7.png','images/syimg8.png','images/syimg9.png','images/syimg10.png',
'images/syimg11.png','images/syimg12.png','images/syimg13.png','images/syimg14.png','images/syimg15.png','images/syimg16.png'];
var imgAll= [];
function preloadImg(arr) {
for(var i =0; i< arr.length ;i++) {
imgAll[i] = new Image();
imgAll[i].src = arr[i];
}
}
preloadImg(imgARR );
//或者延迟的文档加载完毕在加载图片
$(function () {
preloadImg(imgARR );
})