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:

  1. reset image:

    // make sure 'load' event re-triggered img.src = ""; // reset dimensions img.style.width = "auto"; img.style.height = "auto"; 
  2. set new source , wait load

    img.src = newimagesource; 
  3. 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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -