[thelist] JS: Resizing an image?

Frank lists at frankmarion.com
Thu Aug 25 11:15:36 CDT 2005

I'm trying to resize an image by using javascript. The user will upload an 
image, the image will float left in a div. Right now, if the div has a 
lesser height, the image sticks out, if the div has a greater height, the 
images floats loosely. I want to make it so that the height of the image 
always matches the height of the div. In this case, it usually means 
re-adjusting it's dimension by some 2-15px. It's just one of those things 
use to satisfy picky designers.

Here's what I've got, my problem seems to be in changing the size of the 
image itself.  The odd things is that I get no errors

How would you go about it?

    <script type="text/javascript">
       i = document.getElementById('artist_portrait')
       ih = i.height;
       h = document.getElementById('container').offsetHeight; //div
       // i.setAttribute("height",h);  // don't work
        ih = h; // this doesn't work either
       i.height = h;
       // alert(i +' '+ih+' '+h);

See the following url for what it is that I need to adjust

Frank Marion     lists at frankmarion.com      Keep the signal high.

More information about the thelist mailing list