JavaScript加载图像的进度 [英] JavaScript loading progress of an image

查看:110
本文介绍了JavaScript加载图像的进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以让JS在加载图像时获取加载图像的进度?
我想使用HTML5的新Progress标签来显示加载图片的进度。

Is there a way in JS to get the progress of a loading image while the image is being loaded? I want to use the new Progress tag of HTML5 to show the progress of loading images.

我希望有这样的内容:

var someImage = new Image()
someImage.onloadprogress = function(e) { progressBar.value = e.loaded / e.total };
someImage.src = "image.jpg";


推荐答案

尝试使用 article
还有一个现场示例。据我了解,您正在寻找。

Try to use the approach described in this article Also there is a live sample. As I understand that is you were looking for.

这篇关于JavaScript加载图像的进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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