3

I am trying to display a progress bar using the progress of loading images. I tried using onload and onprogress as suggested in one previous answer but only onload works.Thanks in advance.

    var Img = new Image();
    Img.onload = function () {
        console.log("loaded");
    };

    Img.onprogress=function(){
        console.log("progress");
    };

    Img.src = imageUrl;
monsoonrainbow
  • 149
  • 3
  • 10
  • Possible duplicate of [JavaScript loading progress of an image](http://stackoverflow.com/questions/14218607/javascript-loading-progress-of-an-image) – Xeos Jan 10 '17 at 00:41

1 Answers1

0

You need to use Ajax i.e. XHR to get progress events. See more here:

https://stackoverflow.com/a/22593907/6732963

pihvi
  • 309
  • 2
  • 5