View Full Version : Help Needed: Onload to Resize Image

12-06-2006, 11:39 AM
I need some urgent help on a javascript problem. Basicaly I need to load images on the fly to fit into a specific layout on a web page. So I use javascript to perform a resize in order to fit it in:

input type=image onload="javascript:if(this.width>130) this.width=130 src="http://www.cheetahcool.com/images/cheetahcool2.jpg"

(to avoid posting problem, I removed the begining "<" and the ending ">" above)

You can actually see some images are resized in my web site http://www.cheetahcool.com. The problem is, sometime the resize works but some time it doesn't and I don't know why.:confused: :(

Can anyone please help? Is the above script incorrect in some way? I'd love to hear advice on making it work or if you have a better way to resize image. Note: due to various reasons, I can't save and resize the image on disks before loading it.

Thanks a lot!