当前位置:网站首页>Browser independent way to detect when image has been loaded

Browser independent way to detect when image has been loaded

2022-06-23 01:39:00 javail

problem :

In IE, you can onreadystatechange. stay IE in , You can onreadystatechange.There's onload, but I read scary things . Loaded , But I read Something terrible .jQuery wraps up the DOM's load event quite nicely with "ready".jQuery use “ be ready ” Well packed DOM Load events for .It seems likely I am just ignorant of another nice library's implementation of image loading. I just don't seem to know the image loading implementation of another good library .

The context is that I am generating images dynamically (via server callbacks) that can take some time download. Context is that I dynamically generate images ( Callback through the server ), It may take some time to download .In my IE-only code I set the src of the img element, then when the onreadystatechange event fires with the "complete" status, I add it to the DOM so the user sees it. In my IE-only In the code , I set up img Elemental src, Then when onreadystatechange Events to “ complete ” When the status is triggered , I added it to DOM, So that users can see it .

I'd be happy with a "native" JavaScript solution, or a pointer to a library that does the work. I am right. “ Native ”JavaScript Satisfied with the solution or the pointer to the library that performs the work .There's so many libraries out there and I'm sure this is a case of me just not knowing about the right one. There are many libraries there , I'm sure this is the case that I don't know the right Library .That said, we're already jQuery users, so I'm not eager to add a very large library just to get this functionality. in other words , We are already jQuery The user , So I'm not in a hurry to add a very large library to get this functionality .


Solution :

Reference resources : https://stackoom.com/en/question/3RiG
原网站

版权声明
本文为[javail]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202220515066123.html