NaturalHeight function for IE
I discovered to my frustration today that IE does not support the NaturalHeight property of the image tag. With some lateral thinking, it occured to me the easiest way to get this info was for the script to insert a new image tag variable - which would be the original image's size, and return the height of that. Of course you can do the same thing with naturalWidth - but that wasn't needed for me.function getNaturalHeight(img) {frakkle.com
if( img.naturalHeight ) {
return img.naturalHeight;
} else {
lgi = new Image();
lgi.src = img.src;
return lgi.height;
}
}
tags: javascript ie img
No comments:
No trackbacks:
Trackback link:
Please enable javascript to generate a trackback url