Javascript - execute after all images have loaded

前端 未结 9 1364
陌清茗
陌清茗 2020-12-01 05:53

Having read other people\'s questions I thought

window.onload=...

would answer my question. I have tried this but it executes the code the

9条回答
  •  误落风尘
    2020-12-01 06:17

    You can have the onload event on the image that can callback a function that does the processing... Regarding how to handle if all images are loaded, I am not sure if any of the following mechanisms will work:

    have a function that counts the number of images for which onload is called, if this is equal to the total number of images on your page then do your necessary processing.

提交回复
热议问题