What workarounds exist for the `complete` property in FireFox?

前端 未结 7 1703
温柔的废话
温柔的废话 2020-12-17 16:31

I am attempting to use jQuery to determine if an image has properly loaded.

The following works just fine (and returns true or false as of

7条回答
  •  孤城傲影
    2020-12-17 17:20

    You can use load() but beware of Internet Explorer: It won't fire the event, if the image is cached

    if($img[0].readyState === 4){ // image is cached in IE
        alert("Image loaded!");
    }else{
        $img.load(function(){ // for other browsers and IE, if not cached
            alert("Image loaded!");
        });
    }
    

提交回复
热议问题