How to know when images are finished loading
So for result, if the image is, let's say, 5 of width, it returns 28 with IE and 23 with FF. But if I put a delay, the image width is correct. So, I understand that the onload event is not working as I'd expect.
So, for now, what I do is that I set a timeout of 500 milliseconds and then call my function. It's working, but not very good I think...
Here's my code:
var ctrlImg = document.getElementById('ctrlImg');
ctrlImg.src = "/getNb.aspx";
Is there a way to know for sure when an image is loaded?
Yes -- code an event handler for the "onreadystatechange" event. No need for timeouts.
For details, check this search result:
By dmb-job in forum VB Classic
Last Post: 03-08-2006, 06:19 PM
By gokulram in forum Java
Last Post: 03-18-2005, 12:58 PM
Last Post: 10-31-2002, 08:44 PM
By Michael Shutt in forum Web
Last Post: 06-26-2001, 03:25 PM
Last Post: 04-06-2001, 08:42 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL