[thelist] JS: Resizing an image?
Christian Heilmann
codepo8 at gmail.com
Thu Aug 25 11:51:13 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.
Those will be miffed as the quality of HTML resized images is crap, as
there is no real resampling...
> 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?
I wouldn't do it.
However:
Your code works, but you define the height in the CSS and you change
the HTML attribute.
To make both change, you need to set the style.height attribute aswell.
i.height = h; // HTML attribute
i.style.height=h; // CSS style
--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/
More information about the thelist
mailing list