简体   繁体   English

Javascript加载

[英]Javascript onload

I am using xmlhttp to display thumbnails in a div in increments of 15, something like Google Images. 我正在使用xmlhttp在div中以15为增量显示缩略图,类似于Google图片。 When the request starts it turns on the display property of an "loading.gif" which is then turned off when a counter reaches 15. This counter is incremented by the onload event of the each thumbnail. 当请求开始时,它将打开“ loading.gif”的显示属性,然后在计数器达到15时将其关闭。该计数器会随着每个缩略图的onload事件而递增。 My problem is that onload does not fire for broken thumbnails, so my counter sometimes never reaches 15; 我的问题是onload不会为缩略图损坏触发,因此我的计数器有时永远不会达到15; how to solve this? 如何解决呢? I rather not to use Jquery. 我宁愿不使用Jquery。

You can use the onError event as well to remove it or trigger the counter too. 您也可以使用onError事件将其删除或触发计数器。 http://www.w3schools.com/jsref/event_onerror.asp http://www.w3schools.com/jsref/event_onerror.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM