当html中的图像被加载和渲染时,是否有像事件一样的事件? [英] Is there something like a ready event when an image in html is loaded and rendered?

查看:98
本文介绍了当html中的图像被加载和渲染时,是否有像事件一样的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iPad创建一个webview应用程序,并且希望显示splashscreen,直到索引文件和一组图像被加载并呈现。



当所有图像加载并呈现时,我都希望这个splashscreen消失 - 因此用户看不到加载和渲染非缓存图像的典型图像。



在浏览器中是否存在可以捕获的图像渲染事件,或者是否存在可以执行此操作的JavaScript插件?

解决方案

有两个事件监听器DOMContentLoaded和load。所有文件都已完成从所有资源(包括广告和图片)的加载后,加载事件将触发。图片在下载过程中呈现,所以这应该是你正在寻找的。

请参阅演示这里


I am creating a webview app for iPad, and want to show a splashscreen until index file and a set of images is loaded and rendered.

I want this splashscreen to disappear when all images is loaded and rendered - so the user doesn't see the typical image loading and rendering of non cached images.

Is there an event in browsers for image rendering done I can catch, or is there any Javascript plugin out there that can do this?

解决方案

There are two event listeners DOMContentLoaded and load. The load event fires when all files have finished loading from all resources, including ads and images. The images are rendered during download, so this should be what you are looking for.

See the demo here

这篇关于当html中的图像被加载和渲染时,是否有像事件一样的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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