javascript - ie6 img width:auto doesn't work -
i have image element dynamically changed, , if necessary dynamically re-sized fit container.
my current process is:
reset image:
// make sure 'load' event re-triggered img.src = ""; // reset dimensions img.style.width = "auto"; img.style.height = "auto";
set new source , wait load
img.src = newimagesource;
in images
onload
handler, size tested , if necessary, altered:img.style.width = newwidth + "px";
this repeated image changed (infinite).
this works fine browsers tested (ie7,8,9,10, ff, chrome) ie6 setting width/height "auto" seems resize element around 25 x 25 px regardless of actual image's dimensions.
so; there way reset images dimensions equivalent of "auto" dimensions of image subsequently loaded determines elements dimensions ie6?
i believe can write
img.style.width = "";
to set width default value of auto
. apparently img.style.width = "auto";
doesn't work same way.
Comments
Post a Comment