开发者

JavaScript image loading in percents

Is there any way to show "percentage-load-bar" while lo开发者_如何学编程ading an image in js? In other words I want to use this:

var img = new Image();
img.onload = function() {
  document.querySelector('#percents').innerHTML = 'all done';
};

img.onreadystatechange = function(e) {
  document.querySelector('#percents').innerHTML = e.percentsLoaded;
};

img.src = 'http://example.com/image.png';


Javascript has no intermediate events for loading resources. You can however show a loading bar if you are loading more than one image but I'm guessing that's not the case.

If you do really want this I think the only solution is to use Flash, which can do a number of fancy things but .. well .. it's Flash :/

Look at some of the big album-image hosting sites and see if they have a solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜