[removed] Know when an image is fully loaded

前端 未结 7 1163
旧巷少年郎
旧巷少年郎 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:20

    Here's a simple javascript code that works on all browsers:

    var myImage = new Image();
    
    myImage.onload = function() {
        var image_width = myImage.width;
        var image_height = myImage.height;
        $('#pictureEl').html('');           
    };
    
    myImage.src = myUrl;
    

    A jQuery snippet must be doing the same thing, under the hood.

提交回复
热议问题