I have a site where I have to dynamically load images. I must know their width/height before laying them down, so I am using the onload event handler. What I found anyway, is that sometimes those values are 0/0 even in the handler (this happens on Chrome and as I am targeting webkit, this is the browser to use). Is there any way to enforce this? I mean I could use some things like a setTimeout in the case the image is 0/0 and recheck until its done, what I’m looking for is something more clean and possibly using DOM methods…
Share
You’re using the onload event of the image right? If that’s not reliable, I’d try writing the image into the DOM in a hidden element and then getting it’s dimensions.