var arrayBKImages = new Array();
arrayBKImages[0] = new Image();
arrayBKImages[1] = new Image();
arrayBKImages[2] = new Image();
arrayBKImages[3] = new Image();
arrayBKImages[4] = new Image();
arrayBKImages[5] = new Image();
arrayBKImages[6] = new Image();
arrayBKImages[7] = new Image();
arrayBKImages[8] = new Image();
arrayBKImages[9] = new Image();
arrayBKImages[10] = new Image();
imgsCount = arrayBKImages.length;
for(var i=0; i<arrayBKImages.length; i++) {
if (arrayBKImages[i].complete) {
LoadingFn();//显示进度条
} else {
arrayBKImages[i].onload = function() {
LoadingFn();
}
}
} arrayBKImages[0].src = "i0000001.png";
arrayBKImages[1].src = "i0000005.png";
arrayBKImages[2].src = "i0000007.png";
arrayBKImages[3].src = "i0000009.png";
arrayBKImages[4].src = "i0000013.png";
arrayBKImages[5].src = "i0000017.png";
arrayBKImages[6].src = "i0000021.png";
arrayBKImages[7].src = "i0000025.png";
arrayBKImages[8].src = "i0000029.png";
arrayBKImages[9].src = "i0000033.png";
arrayBKImages[10].src = "i0000037.png";
测试发现image.complete属性在火狐下,当第一次加载时为false,刷新的时候为true。不清空缓存是正常的,但是清空缓存后,缓存已经没有这些图片了,complete属性仍为true。结果就是首页被快速打开,但图片仍在一点一点往缓存里加。进度条已经失去真实的意义了。
如果让进度条显示的和清空缓存一样或者和未缓存时一样该怎么做呢?
arrayBKImages[0] = new Image();
arrayBKImages[1] = new Image();
arrayBKImages[2] = new Image();
arrayBKImages[3] = new Image();
arrayBKImages[4] = new Image();
arrayBKImages[5] = new Image();
arrayBKImages[6] = new Image();
arrayBKImages[7] = new Image();
arrayBKImages[8] = new Image();
arrayBKImages[9] = new Image();
arrayBKImages[10] = new Image();
imgsCount = arrayBKImages.length;
for(var i=0; i<arrayBKImages.length; i++) {
if (arrayBKImages[i].complete) {
LoadingFn();//显示进度条
} else {
arrayBKImages[i].onload = function() {
LoadingFn();
}
}
} arrayBKImages[0].src = "i0000001.png";
arrayBKImages[1].src = "i0000005.png";
arrayBKImages[2].src = "i0000007.png";
arrayBKImages[3].src = "i0000009.png";
arrayBKImages[4].src = "i0000013.png";
arrayBKImages[5].src = "i0000017.png";
arrayBKImages[6].src = "i0000021.png";
arrayBKImages[7].src = "i0000025.png";
arrayBKImages[8].src = "i0000029.png";
arrayBKImages[9].src = "i0000033.png";
arrayBKImages[10].src = "i0000037.png";
测试发现image.complete属性在火狐下,当第一次加载时为false,刷新的时候为true。不清空缓存是正常的,但是清空缓存后,缓存已经没有这些图片了,complete属性仍为true。结果就是首页被快速打开,但图片仍在一点一点往缓存里加。进度条已经失去真实的意义了。
如果让进度条显示的和清空缓存一样或者和未缓存时一样该怎么做呢?
解决方案 »
- 各位,帮忙想下这个正则验证,在线等,,急.....
- 在线等急 关于函数执行问题[内详]
- width,posWidth,clientWidth,offsetWidth 这几个Width有什么不同的地方?请高手清楚的讲一下.
- 怎样使一个td的高度等于他的背景图片的高度?
- 请问调度js的工具一般用什么?
- 在javascript中怎么表示服务器变量? var s = <% =myServerVar %>; 的形式怎么不对?
- 怎样用JavaScript清除IE的历史记录(给分88)在线等
- 哪个函数可以将一个字符串中的一段一起转换?
- webpack配置报错!
- 小程序js怎么取值
- Extjs4.0中grid的panel第二次打开不见各个列名
- 网站3个js文件冲突要如何解决
document.write(a.complete)//true
a.src='http://static.googleadsserving.cn/pagead/imgad?id=CICAgICQyeLfIhB4GNgEMggliLTa1MMp2w&_dc='+new Date().getTime();
document.write(a.complete)//false
alert(arrayBKImages[0].complete);
arrayBKImages[1].src = "i0000003.png";
alert(arrayBKImages[1].complete);
arrayBKImages[2].src = "i0000005.png";
alert(arrayBKImages[2].complete);
arrayBKImages[3].src = "i0000007.png";
alert(arrayBKImages[3].complete);
arrayBKImages[4].src = "i0000009.png";
alert(arrayBKImages[4].complete);
arrayBKImages[5].src = "i0000011.png";
alert(arrayBKImages[5].complete);
arrayBKImages[6].src = "i0000013.png";
alert(arrayBKImages[6].complete);
这样写时提示是false。在初次打开Index时。但如果这样写
arrayBKImages[0].src = "i0000001.png";
arrayBKImages[1].src = "i0000003.png";
arrayBKImages[2].src = "i0000005.png";
arrayBKImages[3].src = "i0000007.png";
arrayBKImages[4].src = "i0000009.png";
arrayBKImages[5].src = "i0000011.png";
arrayBKImages[6].src = "i0000013.png";
for(var i=0; i<arrayBKImages.length; i++) {
alert(arrayBKImages[i].complete);
}
除了第一个是false外,其他就都是true了。
在网上查了,是不能把给src赋值的过程放到事件前面的。就是for循环前面的。