如何知道是否已使用javascript加载图像 [英] how to know whether or not a image has been loaded using javascript

查看:140
本文介绍了如何知道是否已使用javascript加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个显示相册的网站,页面正在加载拇指,并在每张图片完全加载之前应用白色叠加。

I'm coding a website that displays picture albums, the page is loading the thumbs and applies white overlays on each picture before they are fully loaded.

我编码这在当地,它的工作正常。
但是上传我服务器上的文件并加载页面几乎没有显示错误,一些白色覆盖不会淡出,因为jQuery load 函数没有被触发,因为图像在脚本加载之前加载

I coded this in local and it works fine. But uploading the files on my server and loading the page brings few errors of display, some white overlay are not fading out because the jQuery load function is not triggered since images load before the script is loaded and being applied.

解决方案是仅对正在执行jQuery脚本时仍然加载的图像应用白色叠加。

The solution would be to apply white overlay only on images that are still loaded when the jQuery script is being executed.

我的问题是如何知道页面中的特定元素是否仍在提取或已完全呈现在屏幕上?

My question is how to know if a specific element in the page is still being fetched or has completely been rendered on the screen ?

注意:这里是 http://www.benjamindegenne.com / portfolio / numeric / upper-playground /

推荐答案

https://github.com/desandro/imagesloaded - 图片加载jQuery插件将为您做到这一点; - )

https://github.com/desandro/imagesloaded - images loaded jQuery plug in will do that for you ;-)

这篇关于如何知道是否已使用javascript加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆