[removed] Know when an image is fully loaded

前端 未结 7 1146
旧巷少年郎
旧巷少年郎 2020-11-30 02:42

If I have a beacon:


I want a method to be called once the beacon request finishes. Somethin

7条回答
  •  [愿得一人]
    2020-11-30 03:24

    You can do it easily in two way.lets see the ways:

    1.Using onload attribute in img tag:

    
    

    This will trigger alert just after the photo is finished loading.

    2.Using EventListener in JavaScript:

    document.getElementsByTagName("img");.addEventListener("load", function loaded(){
      //any code you may need
      }); 
    

    These code goes in your external js file or internal script tag.

    You can do this for every individual img tag using class and id attribute.

提交回复
热议问题